Package org.openbravo.base.model
Class Property
- java.lang.Object
-
- org.openbravo.base.model.Property
-
-
Constructor Summary
Constructors Constructor Description Property()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowDerivedRead()
Identifier, Id, audit info, active, client/organization properties are derived readable, in addition properties which are referenced by other properties are derived readable, all other properties are not derived readable.boolean
allowNullValues()
void
checkIsValidValue(Object value)
Checks if the value of the object is of the correct type and it is not null if the property is mandatory.void
checkIsWritable()
Checks if for an instance of the Entity a value can be written in this property.String
concatenatedAllowedValues()
boolean
doCheckAllowedValue()
Object
getActualDefaultValue()
Returns the Object value of the default, for example a Date property with default value of today will return a new Date() object.Set<String>
getAllowedValues()
String
getColumnId()
String
getColumnName()
String
getDisplayPropertyName()
DomainType
getDomainType()
Entity
getEntity()
int
getFieldLength()
String
getFormattedDefaultValue()
Is used by the code generation of entities.String
getGetterSetterName()
String
getHelp()
Class<?>
getHibernateType()
Property
getIdBasedOnProperty()
List<Property>
getIdParts()
int
getIndexInEntity()
String
getJavaName()
String
getMaxValue()
String
getMinValue()
Module
getModule()
String
getName()
String
getNameOfColumn()
String
getObjectTypeName()
Returns the typename of the object type of this property.Class<?>
getPrimitiveObjectType()
Returns the class of the type of this property, will translate primitive type classes (int) to their object type (java.lang.Long for example).Class<?>
getPrimitiveType()
Property
getReferencedProperty()
In case of an association, returns the property in the associatedEntity
to which this property refers.Integer
getSeqno()
String
getShorterNameTargetEntity()
Used during generate.entities to generate short java type-names if a corresponding java import statement is generated for this type.String
getShorterTypeName()
Used during generate.entities to generate short java type-names if a corresponding java import statement is generated for this type.String
getSimpleTypeName()
The last part of the class name of the type of the property.String
getSqlLogic()
Entity
getTargetEntity()
String
getTransientCondition()
Property
getTranslationProperty()
Property
getTrlParentProperty()
String
getTypeName()
Returns the primitive type name or the class name of the referenced type.PropertyValidator
getValidator()
boolean
hasDefaultValue()
boolean
hasDisplayColumn()
void
initializeFromColumn(Column fromColumn)
Initializes this Property using the information from the Column.protected void
initializeName()
Initializes the name of the property.boolean
isAbsoluteDateTime()
boolean
isAbsoluteTime()
boolean
isActiveColumn()
boolean
isAllowedCrossOrgReference()
Foreign key properties allowing cross organization references can define a link to an object which organization is not in the same organization's natural tree when context is insetCrossOrgReferenceAdminMode
.boolean
isAllowedValue(String value)
boolean
isAuditInfo()
boolean
isBeingReferenced()
Is this a property which is referenced by another property if this === otherProperty.referencedProperty then this method returns true.boolean
isBoolean()
boolean
isChild()
boolean
isChildPropertyInParent()
For FK properties, this flag indicates whether a new property in referenced entity will be created referencing this one.boolean
isClientOrOrganization()
boolean
isCompositeId()
boolean
isComputedColumn()
A property is a computed column when it has sql logic, in this case it is calculated based on a sql formula and is accessed through a proxy.boolean
isDate()
boolean
isDatetime()
Boolean
isDeprecated()
boolean
isDisplayValue()
boolean
isEncrypted()
boolean
isId()
boolean
isIdentifier()
boolean
isImage()
This method is used to determine if this is an image property.boolean
isInactive()
boolean
isMandatory()
boolean
isNumericType()
boolean
isOneToMany()
boolean
isOneToOne()
boolean
isOrderByProperty()
boolean
isParent()
boolean
isPartOfCompositeId()
boolean
isPrimitive()
boolean
isProxy()
Proxy properties are used to access to computed columns.boolean
isStoredInSession()
boolean
isTextualType()
boolean
isTime()
boolean
isTransient()
boolean
isTransient(BaseOBObjectDef bob)
Checks if the property is transient.boolean
isTranslatable()
Returns whether a property is translatable to other languages.boolean
isUpdatable()
boolean
isUsedSequence()
boolean
isUuid()
void
removeHelp()
Removes help comment from this propertyvoid
setActiveColumn(boolean isActiveColumn)
void
setAllowedCrossOrgReference(boolean allowedCrossOrgReference)
void
setAllowedValues(Set<String> allowedValues)
void
setAuditInfo(boolean isAuditInfo)
void
setBeingReferenced(boolean isBeingReferenced)
void
setChild(boolean child)
void
setChildPropertyInParent(boolean isChildPropertyInParent)
void
setClientOrOrganization(boolean isClientOrOrganization)
void
setColumnId(String columnId)
void
setColumnName(String columnName)
void
setCompositeId(boolean isCompositeId)
void
setDate(boolean isDate)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.void
setDatetime(boolean isDatetime)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.void
setDefaultValue(String defaultValue)
void
setDeprecated(Boolean deprecated)
void
setDomainType(DomainType domainType)
void
setEncrypted(boolean encrypted)
void
setEntity(Entity entity)
void
setFieldLength(int fieldLength)
void
setHelp(String help)
Adds help to this property from corresponding column Removes comment escape character sequence and wraps comments over 100 characters.void
setId(boolean id)
void
setIdBasedOnProperty(Property idBasedOnProperty)
void
setIdentifier(boolean identifier)
void
setInactive(boolean isInactive)
void
setIndexInEntity(int indexInEntity)
void
setMandatory(boolean mandatory)
void
setMaxValue(String maxValue)
void
setMinValue(String minValue)
void
setModule(Module module)
void
setName(String name)
void
setNameOfColumn(String nameOfColumn)
void
setOneToMany(boolean oneToMany)
void
setOneToOne(boolean oneToOne)
void
setOrderByProperty(boolean isOrderByProperty)
void
setParent(boolean parent)
void
setPartOfCompositeId(boolean isPartOfCompositeId)
void
setPrimitive(boolean primitive)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.void
setPrimitiveType(Class<?> primitiveType)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.void
setProxy(boolean isProxy)
void
setReferencedProperty(Property referencedProperty)
Sets the referenced property and also thetargetEntity
.void
setSeqno(Integer seqno)
void
setSqlLogic(String sqlLogic)
void
setStoredInSession(boolean storedInSession)
void
setTargetEntity(Entity targetEntity)
void
setTransient(boolean isTransient)
void
setTransientCondition(String transientCondition)
void
setUpdatable(boolean isUpdatable)
void
setUsedSequence(boolean usedSequence)
void
setUuid(boolean isUuid)
void
setValidator(PropertyValidator validator)
String
toString()
-
-
-
Method Detail
-
initializeFromColumn
public void initializeFromColumn(Column fromColumn)
Initializes this Property using the information from the Column.- Parameters:
fromColumn
- the column used to initialize this Property.
-
initializeName
protected void initializeName()
Initializes the name of the property. This is done separately from theinitializeFromColumn
method because to initialize the name also information from other properties is required.
-
isBoolean
public boolean isBoolean()
-
getEntity
public Entity getEntity()
-
setEntity
public void setEntity(Entity entity)
-
isId
public boolean isId()
-
setId
public void setId(boolean id)
-
isPrimitive
public boolean isPrimitive()
-
getReferencedProperty
public Property getReferencedProperty()
In case of an association, returns the property in the associatedEntity
to which this property refers. Returns null if there is no referenced property this occurs in case of a reference to the primary key of the referenced Entity.- Returns:
- the associated property on the other side of the association.
-
setReferencedProperty
public void setReferencedProperty(Property referencedProperty)
Sets the referenced property and also thetargetEntity
.- Parameters:
referencedProperty
- the property referenced by this property
-
getTargetEntity
public Entity getTargetEntity()
-
setTargetEntity
public void setTargetEntity(Entity targetEntity)
-
getPrimitiveType
public Class<?> getPrimitiveType()
- Returns:
- the primitive type defined by the domain type of the property.
- See Also:
getDomainType()
,PrimitiveDomainType.getPrimitiveType()
-
getHibernateType
public Class<?> getHibernateType()
- Returns:
- the type used in the hibernate mapping for a primitive typed property.
- See Also:
getDomainType()
,PrimitiveDomainType.getHibernateType()
-
getColumnName
public String getColumnName()
-
setColumnName
public void setColumnName(String columnName)
-
getFormattedDefaultValue
public String getFormattedDefaultValue()
Is used by the code generation of entities. It will return a String which can be used to set in the generated source code to initialize a property. For example if this is a boolean and the default value in the database for the column is 'Y' then this method will return "true". Will set the default value for a boolean in case it has not yet been set.- Returns:
- the java-valid default
-
isNumericType
public boolean isNumericType()
- Returns:
- true if the class of the primitive type (
getPrimitiveObjectType()
) is a number (extendsNumber
).
-
isTextualType
public boolean isTextualType()
- Returns:
- true if the class of the primitive type (
getPrimitiveObjectType()
) is a textual type (extendsNumber
).
-
getActualDefaultValue
public Object getActualDefaultValue()
Returns the Object value of the default, for example a Date property with default value of today will return a new Date() object.- Returns:
- the java object which can be used to initialize the java member corresponding to this property.
-
allowDerivedRead
public boolean allowDerivedRead()
Identifier, Id, audit info, active, client/organization properties are derived readable, in addition properties which are referenced by other properties are derived readable, all other properties are not derived readable.- Returns:
- true if derived readable for the current user, false otherwise.
- See Also:
isActiveColumn()
,isAuditInfo()
,isBeingReferenced()
,isClientOrOrganization()
,isIdentifier()
,isId()
-
hasDefaultValue
public boolean hasDefaultValue()
-
setDefaultValue
public void setDefaultValue(String defaultValue)
-
isMandatory
public boolean isMandatory()
-
setMandatory
public void setMandatory(boolean mandatory)
-
isIdentifier
public boolean isIdentifier()
-
setIdentifier
public void setIdentifier(boolean identifier)
-
isParent
public boolean isParent()
-
setParent
public void setParent(boolean parent)
-
isChild
public boolean isChild()
-
setChild
public void setChild(boolean child)
-
getTypeName
public String getTypeName()
Returns the primitive type name or the class name of the referenced type. Used by the entity code generation.- Returns:
- a String denoting the class name of values of this property
-
getShorterTypeName
public String getShorterTypeName()
Used during generate.entities to generate short java type-names if a corresponding java import statement is generated for this type.
-
getShorterNameTargetEntity
public String getShorterNameTargetEntity()
Used during generate.entities to generate short java type-names if a corresponding java import statement is generated for this type.
-
getSimpleTypeName
public String getSimpleTypeName()
The last part of the class name of the type of the property. Used by the entity code generation.
-
getObjectTypeName
public String getObjectTypeName()
Returns the typename of the object type of this property. So a property with type int will return "java.lang.Integer". Used by the entity code generation.- Returns:
- the class name of the object type of this property.
-
getPrimitiveObjectType
public Class<?> getPrimitiveObjectType()
Returns the class of the type of this property, will translate primitive type classes (int) to their object type (java.lang.Long for example). Used by the entity code generation.- Returns:
- the Object class for the primitive type
-
allowNullValues
public boolean allowNullValues()
- Returns:
- true if the property potentially allows null values because it is an object type. Used by code generation of entities.
-
getName
public String getName()
-
getGetterSetterName
public String getGetterSetterName()
- Returns:
- the name used for creating a getter/setter in generated code.
-
checkIsWritable
public void checkIsWritable()
Checks if for an instance of the Entity a value can be written in this property. If not then a ValidationException is thrown.- Throws:
ValidationException
-
checkIsValidValue
public void checkIsValidValue(Object value)
Checks if the value of the object is of the correct type and it is not null if the property is mandatory. Throws a ValidationException if the value does not fit the definition of the property.- Parameters:
value
- the value to check- Throws:
ValidationException
-
setName
public void setName(String name)
-
getMinValue
public String getMinValue()
-
setMinValue
public void setMinValue(String minValue)
-
getMaxValue
public String getMaxValue()
-
setMaxValue
public void setMaxValue(String maxValue)
-
getIdBasedOnProperty
public Property getIdBasedOnProperty()
-
setIdBasedOnProperty
public void setIdBasedOnProperty(Property idBasedOnProperty)
-
isOneToOne
public boolean isOneToOne()
-
setOneToOne
public void setOneToOne(boolean oneToOne)
-
isOneToMany
public boolean isOneToMany()
-
setOneToMany
public void setOneToMany(boolean oneToMany)
-
isUuid
public boolean isUuid()
-
setUuid
public void setUuid(boolean isUuid)
-
isUpdatable
public boolean isUpdatable()
-
setUpdatable
public void setUpdatable(boolean isUpdatable)
-
isCompositeId
public boolean isCompositeId()
-
setCompositeId
public void setCompositeId(boolean isCompositeId)
-
isComputedColumn
public boolean isComputedColumn()
A property is a computed column when it has sql logic, in this case it is calculated based on a sql formula and is accessed through a proxy.
-
isProxy
public boolean isProxy()
Proxy properties are used to access to computed columns. Computed columns are not directly within the entity they are defined in, but in a extra entity that is accessed through a proxy, in this way computed columns are lazily calculated.
-
setProxy
public void setProxy(boolean isProxy)
-
isPartOfCompositeId
public boolean isPartOfCompositeId()
-
setPartOfCompositeId
public void setPartOfCompositeId(boolean isPartOfCompositeId)
-
getFieldLength
public int getFieldLength()
-
setFieldLength
public void setFieldLength(int fieldLength)
-
doCheckAllowedValue
public boolean doCheckAllowedValue()
-
isAllowedValue
public boolean isAllowedValue(String value)
-
concatenatedAllowedValues
public String concatenatedAllowedValues()
- Returns:
- a comma delimited list of allowed values, is used for enums.
-
isTransient
public boolean isTransient(BaseOBObjectDef bob)
Checks if the property is transient. It uses the business object and thetransientCondition
to compute if the property is transient (won't be exported to xml).- Parameters:
bob
- the business object used to compute if the property is transient- Returns:
- true if the property is transient and does not need to be exported
-
getValidator
public PropertyValidator getValidator()
-
setValidator
public void setValidator(PropertyValidator validator)
-
getJavaName
public String getJavaName()
-
setOrderByProperty
public void setOrderByProperty(boolean isOrderByProperty)
-
isOrderByProperty
public boolean isOrderByProperty()
-
isTransient
public boolean isTransient()
-
setTransient
public void setTransient(boolean isTransient)
-
isAuditInfo
public boolean isAuditInfo()
-
setAuditInfo
public void setAuditInfo(boolean isAuditInfo)
-
getTransientCondition
public String getTransientCondition()
-
setTransientCondition
public void setTransientCondition(String transientCondition)
-
isClientOrOrganization
public boolean isClientOrOrganization()
-
setClientOrOrganization
public void setClientOrOrganization(boolean isClientOrOrganization)
-
isInactive
public boolean isInactive()
-
setInactive
public void setInactive(boolean isInactive)
-
getModule
public Module getModule()
-
setModule
public void setModule(Module module)
-
getNameOfColumn
public String getNameOfColumn()
-
setNameOfColumn
public void setNameOfColumn(String nameOfColumn)
-
getIndexInEntity
public int getIndexInEntity()
-
setIndexInEntity
public void setIndexInEntity(int indexInEntity)
-
isDatetime
public boolean isDatetime()
-
isAbsoluteDateTime
public boolean isAbsoluteDateTime()
-
isTime
public boolean isTime()
-
isAbsoluteTime
public boolean isAbsoluteTime()
-
isDate
public boolean isDate()
-
isActiveColumn
public boolean isActiveColumn()
-
setActiveColumn
public void setActiveColumn(boolean isActiveColumn)
-
getDomainType
public DomainType getDomainType()
-
setDomainType
public void setDomainType(DomainType domainType)
-
setDate
public void setDate(boolean isDate)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.
-
setDatetime
public void setDatetime(boolean isDatetime)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.
-
setPrimitive
public void setPrimitive(boolean primitive)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.
-
setPrimitiveType
public void setPrimitiveType(Class<?> primitiveType)
Deprecated not used anymore, is computed on the basis of thegetDomainType()
.
-
getColumnId
public String getColumnId()
-
setColumnId
public void setColumnId(String columnId)
-
isBeingReferenced
public boolean isBeingReferenced()
Is this a property which is referenced by another property if this === otherProperty.referencedProperty then this method returns true. Referenced properties are also accessible in derived read mode.- Returns:
- true if this property is being referenced by another property in the model.
- See Also:
getReferencedProperty()
-
setBeingReferenced
public void setBeingReferenced(boolean isBeingReferenced)
-
isEncrypted
public boolean isEncrypted()
-
setEncrypted
public void setEncrypted(boolean encrypted)
-
hasDisplayColumn
public boolean hasDisplayColumn()
- Returns:
- true if the property is a table reference which defines an explicit display column. This display column is then used as the identifier of objects referenced through this property.
-
isDisplayValue
public boolean isDisplayValue()
- Returns:
- true if the property is a table reference which defines an explicit display column. This display column is then used as the identifier of objects referenced through this property.
-
getDisplayPropertyName
public String getDisplayPropertyName()
-
isTranslatable
public boolean isTranslatable()
Returns whether a property is translatable to other languages. A property can be translated in case it has been marked in AD and there are translations installed in the system.
-
getTranslationProperty
public Property getTranslationProperty()
-
getTrlParentProperty
public Property getTrlParentProperty()
-
isStoredInSession
public boolean isStoredInSession()
-
setStoredInSession
public void setStoredInSession(boolean storedInSession)
-
getSeqno
public Integer getSeqno()
-
setSeqno
public void setSeqno(Integer seqno)
-
isUsedSequence
public boolean isUsedSequence()
-
setUsedSequence
public void setUsedSequence(boolean usedSequence)
-
getSqlLogic
public String getSqlLogic()
-
setSqlLogic
public void setSqlLogic(String sqlLogic)
-
isAllowedCrossOrgReference
public boolean isAllowedCrossOrgReference()
Foreign key properties allowing cross organization references can define a link to an object which organization is not in the same organization's natural tree when context is insetCrossOrgReferenceAdminMode
.
-
setAllowedCrossOrgReference
public void setAllowedCrossOrgReference(boolean allowedCrossOrgReference)
- See Also:
isAllowedCrossOrgReference()
-
isImage
public boolean isImage()
This method is used to determine if this is an image property.- Returns:
true
if this property references an AD_Image_ID record. Otherwise, this method returnsfalse
.
-
isChildPropertyInParent
public boolean isChildPropertyInParent()
For FK properties, this flag indicates whether a new property in referenced entity will be created referencing this one.
-
setChildPropertyInParent
public void setChildPropertyInParent(boolean isChildPropertyInParent)
- See Also:
isChildPropertyInParent()
-
getHelp
public String getHelp()
-
setHelp
public void setHelp(String help)
Adds help to this property from corresponding column Removes comment escape character sequence and wraps comments over 100 characters. Makes sure it doesn't generate warnings by escaping "@"- Parameters:
help
- Help comment to add to this property
-
removeHelp
public void removeHelp()
Removes help comment from this property
-
isDeprecated
public Boolean isDeprecated()
-
setDeprecated
public void setDeprecated(Boolean deprecated)
-
-