Class DFFields


  • public final class DFFields
    extends java.lang.Object
    Utility methods for DFField.
    Author:
    pzajac
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DFFields.Predicates
      Predicates related to DFFields.
    • 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 with DFFieldCalcCapability 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)
      Gets fields that belong to a vertex.
      static java.util.List<? extends DFField> forVertex​(DFDataTree.Vertex vertex, boolean recursive)
      Gets fields which belong to a vertex and its descendants reachable recursively via N:1 or 1:1 relationships.
      static java.util.List<? extends DFField> forVertexState​(DFResultSet.VertexState vertexState)
      Gets fields that belong to a vertexState.
      static java.util.List<? extends DFField> forVertexState​(DFResultSet.VertexState vertexState, boolean recursive)
      Gets fields which belong to a vertexState and its descendants reachable recursively via N:1 or 1:1 relationships.
      static java.util.List<? extends DFField> getCategoryFields​(DFEntity entity)
      Deprecated.
      use getGroupFields(DFEntity) instead; this method will be removed in post-5.12 release
      static java.util.List<? extends DFField> getCategoryFields​(java.util.List<? extends DFField> fields)
      Deprecated.
      use getGroupFields(List) instead; this method will be removed in post-5.12 release
      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.
      static java.util.List<? extends DFField> getGroupFields​(java.util.List<? extends DFField> fields)
      Take the given fields and returns only those which are appropriate to be used as a group field.
      static DFField getIDField​(DFResultSet.VertexState vs)
      Return ID field for the entity represented by the vertex of the given vertex state.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 given fields 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.
        use getGroupFields(DFEntity) instead; this method will be removed in post-5.12 release
        Return 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.
        use getGroupFields(List) instead; this method will be removed in post-5.12 release
        Take the given fields 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 used
        scale - if value is -1 default value will be used
        env - 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 used
        env - 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 used
        env - 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 used
        mimeType - 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 entity
        fieldName - New field name
        mimeType - 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 urlTemplate
        env - 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 entity
        fieldName - New CT field name
        fieldType - Field type - currently only these types are supported: GenericColumnType.FLOAT, GenericColumnType.INTEGER, GenericColumnType.TEXT, GenericColumnType.BOOLEAN
        formula - The formula
        env - 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 type Double or Float. As of 16.5.2 the values are Double, but for backwards compatibility Float 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
      • 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 has DFFieldCalcCapability.
      • 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
      • 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 with DFFieldCalcCapability 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)
        Gets fields that belong to a vertexState. This method delegates to forVertexState(VertexState, boolean) with the recursive parameter set to false. It's a convenience method for calling vertexState.getVertex().getEntity().getFields().getItems().
        Parameters:
        vertexState - The vertex state to get fields for.
        Returns:
        An immutable list of DFFields that belong the vertexState's vertex.
      • forVertexState

        public static java.util.List<? extends DFField> forVertexState​(DFResultSet.VertexState vertexState,
                                                                       boolean recursive)
        Gets fields which belong to a vertexState and its descendants reachable recursively via N:1 or 1:1 relationships.
        Parameters:
        vertexState - The vertex state to get fields for.
        recursive - If true the method will follow N:1 and 1:1 relationships from the vertexState.getVertex() recursively and collect all fields in all vertices that it can reach. If false the method will just return the fields from the vertexState.getVertex() itself.
        Returns:
        An immutable list of DFFields.
        Since:
        6.4
      • forVertex

        public static java.util.List<? extends DFField> forVertex​(DFDataTree.Vertex vertex)
        Gets fields that belong to a vertex. This method delegates to forVertex(com.im.df.api.ddl.DFDataTree.Vertex, boolean) with the recursive parameter set to false. It's a convenience method for calling vertex.getEntity().getFields().getItems().
        Parameters:
        vertex - The vertex to get fields for.
        Returns:
        An immutable list of DFFields that belong the vertex.
      • forVertex

        public static java.util.List<? extends DFField> forVertex​(DFDataTree.Vertex vertex,
                                                                  boolean recursive)
        Gets fields which belong to a vertex and its descendants reachable recursively via N:1 or 1:1 relationships.
        Parameters:
        vertex - The vertex to get fields for.
        recursive - If true the method will follow N:1 and 1:1 relationships from the vertex recursively and collect all fields in all vertices that it can reach. If false the method will just return the fields from the vertex itself.
        Returns:
        An immutable list of DFFields.
        Since:
        6.3
      • getIDField

        public static DFField getIDField​(DFResultSet.VertexState vs)
        Return ID field for the entity represented by the vertex of the given vertex state.
        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 and UPDATE is disabled => returns false
        • If field's entity has DFDataEditCapability and UPDATE is disabled => returns false
        Otherwise returns true. This method is not testing DFEntityDataProvider's lockable.
        Parameters:
        field - field of interest
        Returns:
        whether field's value is editable