Package com.im.df.api.ddl
Class DFFields
- java.lang.Object
-
- com.im.df.api.ddl.DFFields
-
public final class DFFields extends java.lang.Object
Utility methods forDFField
.- Author:
- pzajac
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DFFields.Predicates
Predicates related toDFField
s.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DFField
createBinaryField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new binary standard field.static DFField
createBooleanField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new boolean standard field.static DFField
createChemTermsField(DFEntity entity, java.lang.String fieldName, com.im.commons.db.ddl.GenericColumnType fieldType, java.lang.String formula, com.im.commons.progress.DFEnvironmentRW env)
Creates a new chemical terms field inside given entity according to provided parameters.static DFField
createDateField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new date field with default column type.static DFField
createDateField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env, com.im.commons.db.ddl.DBDatabaseInfo.ColumnSQLType sqlType)
Create new date field with specific column type.static DFField
createDynamicURLField(DFEntity entity, java.lang.String fieldName, java.lang.String mimeType, java.lang.String urlTemplate, DFField[] params, com.im.commons.progress.DFEnvironmentRW env)
Create a new dynamic URL field.static DFField
createFloatField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, int scale, com.im.commons.progress.DFEnvironmentRW env)
Create new float standard field with default column type.static DFField
createIntegerField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new integer standard field.static DFField
createStaticURLField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, java.lang.String mimeType, com.im.commons.progress.DFEnvironmentRW env)
Create a new static URL field with default column type.static DFField
createTextArrayField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, com.im.commons.progress.DFEnvironmentRW env)
Create new text list field with default column type (VARCHAR).static DFField
createTextField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, com.im.commons.progress.DFEnvironmentRW env)
Create new text standard field with default column type (VARCHAR).static java.util.Collection<? extends DFField>
findDependentFields(java.util.Collection<? extends DFField> fields)
Finds calculated fields (means fields withDFFieldCalcCapability
that use the fields passed in.static DFField
findStructureField(DFEntity entity)
Finds Structure field if it's available.static java.util.List<? extends DFField>
forVertex(DFDataTree.Vertex vertex)
static java.util.List<? extends DFField>
forVertex(DFDataTree.Vertex vertex, boolean recursive)
static java.util.List<? extends DFField>
forVertexState(DFResultSet.VertexState vertexState)
Getsfields
that belong to avertexState
.static java.util.List<? extends DFField>
forVertexState(DFResultSet.VertexState vertexState, boolean recursive)
Getsfields
which belong to avertexState
and its descendants reachable recursively viaN:1
or1:1
relationships.static java.util.List<? extends DFField>
getCategoryFields(DFEntity entity)
Deprecated.usegetGroupFields(DFEntity)
instead; this method will be removed in post-5.12 releasestatic java.util.List<? extends DFField>
getCategoryFields(java.util.List<? extends DFField> fields)
Deprecated.usegetGroupFields(List)
instead; this method will be removed in post-5.12 releasestatic java.util.List<? extends DFField>
getGroupFields(DFEntity entity)
Return fields belonging to the given entity which are appropriate to be used as a group field.static java.util.List<? extends DFField>
getGroupFields(java.util.List<? extends DFField> fields)
Take the givenfields
and returns only those which are appropriate to be used as a group field.static DFField
getIDField(DFResultSet.VertexState vs)
static boolean
hasEditableValues(DFField field)
Tests if values of the given field can be edited.static boolean
isBinary(DFField field)
Test if this field is of Binary type.static boolean
isBoolean(DFField field)
Test if this field is of Boolean type.static boolean
isCalculated(DFField field)
Test if this field is Calculated field.static boolean
isChemicalTerms(DFField field)
Test if this field is Chemical terms field.static boolean
isDate(DFField field)
Test if this field is of Date type.static boolean
isDateTime(DFField field)
Informs whether field can store date and time or only date.static boolean
isDBField(DFField field)
Test if this field is DB based.static boolean
isDynamicURL(DFField field)
Test if this field is of Dynamic URL type.static boolean
isEditableValue(DFField field)
Check whether or not data for the field in entity can be edited.static boolean
isExtension(DFField field)
Test if this field is Extension field.static boolean
isFloat(DFField field)
Test if this field is of a decimal number type.static boolean
isID(DFField field)
Tests whether the given field is an ID field within its owning entity.static boolean
isInteger(DFField field)
Test if this field is of Integer type.static boolean
isRelationField(DFField field)
Check if column of field represents foreign key.static boolean
isSortable(DFField field)
Informs whether the field is capable to be sorted.static boolean
isStandard(DFField field)
Test if this field is Standard field.static boolean
isStaticURL(DFField field)
Test if this field is of Static URL type.static boolean
isStructure(DFField field)
Test if this field is of Structure type.static boolean
isText(DFField field)
Test if this field is of Text type.static boolean
isURL(DFField field)
Test if this field is of URL type.static java.util.List<java.lang.String>
toNames(java.util.List<? extends DFField> fields)
Deprecated.
-
-
-
Method Detail
-
isID
public static boolean isID(DFField field)
Tests whether the given field is an ID field within its owning entity.- Parameters:
field
- field to be checked- Returns:
- if the field is an ID field
-
toNames
@Deprecated public static java.util.List<java.lang.String> toNames(java.util.List<? extends DFField> fields)
Deprecated.Function mapping fields to their names.- Parameters:
fields
- fields to map- Returns:
- fields' names
-
getGroupFields
public static java.util.List<? extends DFField> getGroupFields(DFEntity entity)
Return fields belonging to the given entity which are appropriate to be used as a group field. I.e. the data represented by such field can be partitioned into disjoint groups in sensible manner without using explicit equivalence relation. Examples of such fields are integer, text, boolean, etc. fields. Counter example is float field where explicit equivalence relation is needed to get disjoint equivalence classes.- Parameters:
entity
- the entity- Returns:
- group fields
-
getGroupFields
public static java.util.List<? extends DFField> getGroupFields(java.util.List<? extends DFField> fields)
Take the givenfields
and returns only those which are appropriate to be used as a group field. I.e. the data represented by such field can be partitioned into disjoint groups in sensible manner without using explicit equivalence relation. Examples of such fields are integer, text, boolean, etc. fields. Counter example is float field where explicit equivalence relation is needed to get disjoint equivalence classes.- Parameters:
fields
- fields from which to select group fields- Returns:
- group fields
-
getCategoryFields
@Deprecated public static java.util.List<? extends DFField> getCategoryFields(DFEntity entity)
Deprecated.usegetGroupFields(DFEntity)
instead; this method will be removed in post-5.12 releaseReturn fields belonging to the given entity which are appropriate to be used as a category field. That is integer, text, boolean, etc. fields.- Parameters:
entity
- the entity- Returns:
- category fields
-
getCategoryFields
@Deprecated public static java.util.List<? extends DFField> getCategoryFields(java.util.List<? extends DFField> fields)
Deprecated.usegetGroupFields(List)
instead; this method will be removed in post-5.12 releaseTake the givenfields
and returns only those which are appropriate to be used as a category field. That is integer, text, boolean, etc. fields.- Parameters:
fields
- fields from which to select category fields- Returns:
- category fields
-
createIntegerField
public static DFField createIntegerField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new integer standard field.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.env
- Locked environment.- Returns:
- new integer field
-
createBooleanField
public static DFField createBooleanField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new boolean standard field.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.env
- Locked environment.- Returns:
- new boolean field.
-
createFloatField
public static DFField createFloatField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, int scale, com.im.commons.progress.DFEnvironmentRW env)
Create new float standard field with default column type.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.size
- if value is -1 default value will be usedscale
- if value is -1 default value will be usedenv
- Locked environment.- Returns:
- new float field.
-
createTextField
public static DFField createTextField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, com.im.commons.progress.DFEnvironmentRW env)
Create new text standard field with default column type (VARCHAR). If the default column type can't be created (e.g. because the size exceeds VARCHAR's limit on a particular DB, the following types are tried:- CLOB
- TEXT
- BLOB
- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.size
- of column, if value is -1 default value will be usedenv
- Locked environment.- Returns:
- new text field
-
createTextArrayField
public static DFField createTextArrayField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, com.im.commons.progress.DFEnvironmentRW env)
Create new text list field with default column type (VARCHAR). If the default column type can't be created (e.g. because the size exceeds VARCHAR's limit on a particular DB, the following types are tried:- CLOB
- TEXT
- BLOB
- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.size
- of column, if value is -1 default value will be usedenv
- Locked environment.- Returns:
- new text list field
-
createDateField
public static DFField createDateField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new date field with default column type.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.env
- Locked environment.- Returns:
- new date field
-
createDateField
public static DFField createDateField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env, com.im.commons.db.ddl.DBDatabaseInfo.ColumnSQLType sqlType)
Create new date field with specific column type.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.env
- Locked environment.sqlType
- Specified sql type- Returns:
- new date field
- Since:
- 16.7.11
-
createBinaryField
public static DFField createBinaryField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, com.im.commons.progress.DFEnvironmentRW env)
Create new binary standard field.- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.env
- Locked environment.- Returns:
- new integer field
-
createStaticURLField
public static DFField createStaticURLField(DFEntity entity, java.lang.String fieldName, java.lang.String columnName, int size, java.lang.String mimeType, com.im.commons.progress.DFEnvironmentRW env)
Create a new static URL field with default column type. This field is actually- Parameters:
entity
- Target entity.fieldName
- Name of new field.columnName
- Name of column for the new field.size
- of column, if value is -1 default value will be usedmimeType
- mime type of target - for example "text/html", "image", etc.env
- Locked environment.- Returns:
- new text field
-
createDynamicURLField
public static DFField createDynamicURLField(DFEntity entity, java.lang.String fieldName, java.lang.String mimeType, java.lang.String urlTemplate, DFField[] params, com.im.commons.progress.DFEnvironmentRW env)
Create a new dynamic URL field.- Parameters:
entity
- The target entityfieldName
- New field namemimeType
- Mime type for content referenced by URL (e.g. "text/html" or "image")urlTemplate
- URL template in format like "http://www.google.com/search?q="{0}"params
- Fields used in urlTemplateenv
- Environment with lock- Returns:
- New dynamic URL field
-
createChemTermsField
public static DFField createChemTermsField(DFEntity entity, java.lang.String fieldName, com.im.commons.db.ddl.GenericColumnType fieldType, java.lang.String formula, com.im.commons.progress.DFEnvironmentRW env)
Creates a new chemical terms field inside given entity according to provided parameters.- Parameters:
entity
- The target entityfieldName
- New CT field namefieldType
- Field type - currently only these types are supported:GenericColumnType.FLOAT
,GenericColumnType.INTEGER
,GenericColumnType.TEXT
,GenericColumnType.BOOLEAN
formula
- The formulaenv
- The environment with lock- Returns:
- Newly created CT field
-
findStructureField
public static DFField findStructureField(DFEntity entity)
Finds Structure field if it's available. For standard entities it returns null. Currently JChem tables support only one structure field, so it's unambiguous what field is returned.- Parameters:
entity
- The entity to be scanned- Returns:
- structure field or null if it doesn't exist
- Since:
- 5.12
-
isInteger
public static boolean isInteger(DFField field)
Test if this field is of Integer type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldIntegerCapability
-
isFloat
public static boolean isFloat(DFField field)
Test if this field is of a decimal number type. Values in a decimal number field can be either of java typeDouble
orFloat
. As of 16.5.2 the values areDouble
, but for backwards compatibilityFloat
is still supported.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldFloatCapability
-
isText
public static boolean isText(DFField field)
Test if this field is of Text type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldTextCapability
-
isBoolean
public static boolean isBoolean(DFField field)
Test if this field is of Boolean type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldBooleanCapability
-
isDate
public static boolean isDate(DFField field)
Test if this field is of Date type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldDateCapability
-
isDateTime
public static boolean isDateTime(DFField field)
Informs whether field can store date and time or only date.- Parameters:
field
- Field bound to widget or renderer- Returns:
true
if field can store date and time;false
if field can store only date- Since:
- 16.6.13
-
isStructure
public static boolean isStructure(DFField field)
Test if this field is of Structure type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldStructureCapability
-
isBinary
public static boolean isBinary(DFField field)
Test if this field is of Binary type.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldBinaryCapability
-
isURL
public static boolean isURL(DFField field)
Test if this field is of URL type. See alsoisDynamicURL(com.im.df.api.ddl.DFField)
and {- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldURLCapability
- it means it true for both: dynamic and static column
-
isDynamicURL
public static boolean isDynamicURL(DFField field)
Test if this field is of Dynamic URL type. Dynamic URL field is a field which doesn't have a database column and URL is calculated on fly from a formula - e.g. www.chemaxon.com/search-results/?q={0}- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldURLCapability
and also hasDFFieldCalcCapability
.
-
isStaticURL
public static boolean isStaticURL(DFField field)
Test if this field is of Static URL type. Static URL field is a field which contains URL as texts and it has a database column (it's subtype of text field (isText(com.im.df.api.ddl.DFField)
)- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldURLCapability
and doesn't haveDFFieldCalcCapability
.
-
isCalculated
public static boolean isCalculated(DFField field)
Test if this field is Calculated field.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldCalculatedCapability
-
isExtension
public static boolean isExtension(DFField field)
Test if this field is Extension field.- Parameters:
field
- field to be tested- Returns:
- true if field has
DFFieldExtensionCapability
, false otherwise
-
isChemicalTerms
public static boolean isChemicalTerms(DFField field)
Test if this field is Chemical terms field.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DFFieldChemicalTermsCapability
-
isStandard
public static boolean isStandard(DFField field)
Test if this field is Standard field. Currently it means field is database field AND (not calculated) AND (not chemical terms).- Parameters:
field
- Field to be tested- Returns:
- true if field has
DBFieldCapability
and is notisCalculated(com.im.df.api.ddl.DFField)
is notisChemicalTerms(com.im.df.api.ddl.DFField)
-
isDBField
public static boolean isDBField(DFField field)
Test if this field is DB based.- Parameters:
field
- Field to be tested- Returns:
- true if field has
DBFieldCapability
- Since:
- 17.3.20
-
isSortable
public static boolean isSortable(DFField field)
Informs whether the field is capable to be sorted.- Parameters:
field
-- Returns:
- true if the field can be sorted, false otherwise
- Since:
- 19.19.0
-
findDependentFields
public static java.util.Collection<? extends DFField> findDependentFields(java.util.Collection<? extends DFField> fields)
Finds calculated fields (means fields withDFFieldCalcCapability
that use the fields passed in.- Parameters:
fields
- The fields to find dependencies for.- Returns:
- A collection of calculated fields that use one or more of the fields passed in as their bound parameters.
-
isEditableValue
public static boolean isEditableValue(DFField field)
Check whether or not data for the field in entity can be edited.- Parameters:
field
- input field.- Returns:
- true if data are editable.
-
isRelationField
public static boolean isRelationField(DFField field)
Check if column of field represents foreign key.- Parameters:
field
- input field.- Returns:
- true if field represents foreign key.
-
forVertexState
public static java.util.List<? extends DFField> forVertexState(DFResultSet.VertexState vertexState)
Getsfields
that belong to avertexState
. This method delegates toforVertexState(VertexState, boolean)
with therecursive
parameter set tofalse
. It's a convenience method for callingvertexState.getVertex().getEntity().getFields().getItems()
.- Parameters:
vertexState
- The vertex state to get fields for.- Returns:
- An immutable list of
DFField
s that belong thevertexState
's vertex.
-
forVertexState
public static java.util.List<? extends DFField> forVertexState(DFResultSet.VertexState vertexState, boolean recursive)
Getsfields
which belong to avertexState
and its descendants reachable recursively viaN:1
or1:1
relationships.- Parameters:
vertexState
- The vertex state to get fields for.recursive
- Iftrue
the method will followN:1
and1:1
relationships from thevertexState.getVertex()
recursively and collect all fields in all vertices that it can reach. Iffalse
the method will just return the fields from thevertexState.getVertex()
itself.- Returns:
- An immutable list of
DFField
s. - Since:
- 6.4
-
forVertex
public static java.util.List<? extends DFField> forVertex(DFDataTree.Vertex vertex)
Getsfields
that belong to avertex
. This method delegates toforVertex(com.im.df.api.ddl.DFDataTree.Vertex, boolean)
with therecursive
parameter set tofalse
. It's a convenience method for callingvertex.getEntity().getFields().getItems()
.- Parameters:
vertex
- The vertex to get fields for.- Returns:
- An immutable list of
DFField
s that belong thevertex
.
-
forVertex
public static java.util.List<? extends DFField> forVertex(DFDataTree.Vertex vertex, boolean recursive)
Getsfields
which belong to avertex
and its descendants reachable recursively viaN:1
or1:1
relationships.- Parameters:
vertex
- The vertex to get fields for.recursive
- Iftrue
the method will followN:1
and1:1
relationships from thevertex
recursively and collect all fields in all vertices that it can reach. Iffalse
the method will just return the fields from thevertex
itself.- Returns:
- An immutable list of
DFField
s. - Since:
- 6.3
-
getIDField
public static DFField getIDField(DFResultSet.VertexState vs)
- Parameters:
vs
- the vertex state of interest- Returns:
- the ID field
-
hasEditableValues
public static boolean hasEditableValues(DFField field)
Tests if values of the given field can be edited. This method is testing only:- If field's "required" property is AUTO => returns
false
- If field has
DFDataEditCapability
andUPDATE
is disabled => returnsfalse
- If field's entity has
DFDataEditCapability
andUPDATE
is disabled => returnsfalse
true
. This method is not testingDFEntityDataProvider's lockable
.- Parameters:
field
- field of interest- Returns:
- whether field's value is editable
- If field's "required" property is AUTO => returns
-
-