Class DSField
- All Implemented Interfaces:
com.isomorphic.util.IDoNotAdapt,Map,org.apache.commons.collections4.Get,org.apache.commons.collections4.IterableGet,org.apache.commons.collections4.IterableMap,org.apache.commons.collections4.Put
Contains accessors for all documented DataSource properties and a general getProperty() API for retrieving your own properties for custom DataSource implementations.
-
Method Summary
Modifier and TypeMethodDescriptionReturns property name for this field: ReturnsvalueXPathif specified.Returns the foreign key, if set.Returns value for "includeFrom" property of this field if set,nullotherwiseFor amany-to-manyRelation Field only, returns the name of the join DataSource - ie the third dataSource "in the middle" of the relationship.Returns the length of this field, if specified.getListProperty(String property) Returns the value of the specified attribute as a List.getMapProperty(String property) Returns the value of the specified attribute as a Map.getName()Returns the name of this field.Returns the native name of this field.getObjectProperty(String property) Returns the value of the specified element(s) as an Object.ReturnsotherFKsproperty, if set.getProperty(String property) For an XML DataSource, returns the value of the specified attribute as a string.For aone-to-manyormany-to-manyRelation Field, returns the name of the related DataSource.getTitle()Returns the title of this field, if any.Returns the i18n message for the localized field title, otherwise returnsStringtitle, if any.Returns the i18n key for the field title if it is localized, otherwise returnsnull.getType()Returns the type of this field.Returns the List of Validators defined on this DSFieldFor an XML DataSource, returns the XPath expression used as alternative way to set the field value.For an XML DataSource, returns the XPath expression used to retrieve the field value.booleanReturns true if this field is a one-to-many Relation Field - ie, a field that declares multiple:true and a foreignKey relationship to a "child" dataSource.booleanReturns true if this field value is auto-generated by data base or ORM provider, false otherwise.booleanReturns true if this field value is calculated via "customSQLExpression", "template", "formula" or "valueOperation" attributes, false otherwise.booleanReturns true if this field might be required.booleanReturns the value of this field's "inapplicable" property (default false)booleanReturns true if this field is a many-to-many Relation Field - ie, a field that declares multiple:true and a foreignKey relationship to a related dataSource, via a third "join" dataSource.booleanReturns true if this field is a primary key, false otherwise.booleanReturns true if this field is either aone-to-manyormany-to-manyRelation FieldbooleanReturns true if this field is required, false otherwise.booleanReturns true if this is a field of binary type that also has "encodeInResponse" set
-
Method Details
-
is1ManyRelation
public boolean is1ManyRelation()Returns true if this field is a one-to-many Relation Field - ie, a field that declares multiple:true and a foreignKey relationship to a "child" dataSource. See the "Relations" article in the client documentation for more details- Returns:
- true if this field is a one-to-many relation field, otherwise false
-
isManyManyRelation
public boolean isManyManyRelation()Returns true if this field is a many-to-many Relation Field - ie, a field that declares multiple:true and a foreignKey relationship to a related dataSource, via a third "join" dataSource. See the "Relations" article in the client documentation for more details- Returns:
- true if this field is a many-to-many relation field, otherwise false
-
isRelation
public boolean isRelation()Returns true if this field is either aone-to-manyormany-to-manyRelation Field- Returns:
- true if this field is either a one-to-many or many-to-many relation field, otherwise false
-
getRelatedDSName
For aone-to-manyormany-to-manyRelation Field, returns the name of the related DataSource. See the "Relations" article in the client documentation for more details- Returns:
- The name of the related DataSource if this field is a one-to-many or many-to-many relation field, otherwise null
-
getJoinDSName
For amany-to-manyRelation Field only, returns the name of the join DataSource - ie the third dataSource "in the middle" of the relationship. See the "Relations" article in the client documentation for more details- Returns:
- The name of the join DataSource if this field is a many-to-many relation field, otherwise null
-
getName
Returns the name of this field.- Returns:
- the name of this field
-
isRequired
public boolean isRequired()Returns true if this field is required, false otherwise.- Returns:
- true if this field is required, false otherwise
-
isConditionallyRequired
public boolean isConditionallyRequired()Returns true if this field might be required. This causes the system to look for and run a "requires" validator on this field, rather than just looking at the "required" flag- Returns:
- true if this field is required, false otherwise
-
getType
Returns the type of this field.Valid values include (please see the client-side documentation for details of what these types mean):
- text
- boolean
- integer
- float
- date
- datetime
- time
- enum
- intEnum
- sequence
- link
- image
- binary
- imageFile
- password
- modifier
- modifierTimestamp
- creator
- creatorTimestamp
- Returns:
- the type of this field
-
getLength
Returns the length of this field, if specified.- Returns:
- the length of this field, if specified
-
getTitle
Returns the title of this field, if any. Note that if field title is localized, the i18n message for the field title will be returned.- Returns:
- the title of this field, if any
-
getTitle
Returns the i18n message for the localized field title, otherwise returnsStringtitle, if any.- Parameters:
locale-java.util.Localeto use. Ifnullis passed default locale will be used.- Returns:
- i18n message for the localized field title, otherwise
Stringtitle, if any.
-
getTitleKey
Returns the i18n key for the field title if it is localized, otherwise returnsnull.- Returns:
- i18 key for the field title if any or
nullotherwise
-
isPrimaryKey
public boolean isPrimaryKey()Returns true if this field is a primary key, false otherwise.- Returns:
- true if this field is a primary key, false otherwise
-
isAutoGenerated
public boolean isAutoGenerated()Returns true if this field value is auto-generated by data base or ORM provider, false otherwise. Field is auto-generated if either field type is "sequence" or "autoGenerated" property is set to true.- Returns:
- true if this field is auto-generated, false otherwise
-
getForeignKey
Returns the foreign key, if set.If set, declares that this field holds values that can be matched to values from another DataSource field, to create a relationship between records from different DataSources or even records within the same DataSource.
The format of the foreign key is
<dataSourceId>.<fieldName>.- Returns:
- the foreign key, if set
-
getOtherFKs
ReturnsotherFKsproperty, if set.In addition to regular
foreign keythis property defines additional foreign keys if field is related to multiple DataSources. This property may include the FK defined in "foreignKey" property as well.The format of the otherFKs is coma separated foreign key sets, for example:
<firstDS>.<fieldName>,<secondDS>.<fieldName>.Note that this property works only as an addition to regular FK, i.e. if
foreignKeyis not set, then foreign keys inotherFKwill be completely ignored.- Returns:
- coma separated foreign keys, if set
-
getNativeName
Returns the native name of this field.- Returns:
- the native name of this field
-
getValueXPath
For an XML DataSource, returns the XPath expression used to retrieve the field value. This expression will be evaluated relative to the record element.- Returns:
- the XPath expression
-
getValueWriteXPath
For an XML DataSource, returns the XPath expression used as alternative way to set the field value. This expression will be evaluated relative to the record element.- Returns:
- the XPath expression
-
isCalculated
public boolean isCalculated()Returns true if this field value is calculated via "customSQLExpression", "template", "formula" or "valueOperation" attributes, false otherwise.- Returns:
- true if this is calculated field, false otherwise
-
getProperty
For an XML DataSource, returns the value of the specified attribute as a string.- Parameters:
property- the name of the attribute- Returns:
- the value of the specified attribute as a string
-
getObjectProperty
Returns the value of the specified element(s) as an Object.Custom XML is transformed to Strings or Java collections by the following rules:
- Elements with just text (no child elements or attributes) become Strings
- Elements with child elements or attributes become Maps containing data derived from their subelements
- Repeating elements (more than one of the same name at the same level) become Lists
- Map
<field>
<mapCustomProperty key1="value1" key2="value2" />
</field> - List of String
<field>
<listCustomProperty>ListElement1</listCustomProperty>
<listCustomProperty>ListElement2</listCustomProperty> </field> - List of Map
<field>
<mapCustomProperty key1="value1" key2="value2" />
<mapCustomProperty key1="value1" key2="value2" />
</field>
Sample XML:
- Parameters:
property- the name of the element(s)- Returns:
- the value of the specified element(s) as an Object
- See Also:
-
getListProperty
Returns the value of the specified attribute as a List.- Parameters:
property- the name of the attribute- Returns:
- the value of the specified attribute as a List
- Throws:
ClassCastException- if requested property is not instanceof List- See Also:
-
getMapProperty
Returns the value of the specified attribute as a Map.- Parameters:
property- the name of the attribute- Returns:
- the value of the specified attribute as a Map
- Throws:
ClassCastException- if requested property is not instanceof Map- See Also:
-
getProperty(String)getObjectProperty(String)getListProperty(String)LocaleMessage.getKey()
-
getValidators
Returns the List of Validators defined on this DSField- Returns:
- the List of Validators defined on this DSField
-
getIncludeFrom
Returns value for "includeFrom" property of this field if set,nullotherwise -
getBeanPropertyName
Returns property name for this field:- Returns
valueXPathif specified. Supports only simple XPath definitions: "property/subProperty/subSubProperty". If XPath starts with slash ('/') - it is trimmed. Replaces slashes ('/') with periods ('.'). - For simple properties property name matches field name.
- Returns:
Stringbean property name. Can be composed of subproperties (for example: "address.zipCode").
- Returns
-
shouldEncodeInResponse
public boolean shouldEncodeInResponse()Returns true if this is a field of binary type that also has "encodeInResponse" set -
isInapplicable
public boolean isInapplicable()Returns the value of this field's "inapplicable" property (default false)
-