Class DataDefinitionBuilder

java.lang.Object
io.vertigo.datamodel.data.definitions.DataDefinitionBuilder
All Implemented Interfaces:
io.vertigo.core.lang.Builder<DataDefinition>

public final class DataDefinitionBuilder extends Object implements io.vertigo.core.lang.Builder<DataDefinition>
This class must be used to build a DtDefinition. Each dataDefinition must have a name following this pattern DT_XXX_YYYY
Author:
pchretien
  • Method Details

    • withPackageName

      public DataDefinitionBuilder withPackageName(String packageName)
      Sets packageName
      Parameters:
      packageName - the name of the package (nullable)
      Returns:
      this builder
    • withFragment

      public DataDefinitionBuilder withFragment(DataDefinition fragment)
      Sets fragment
      Parameters:
      fragment - Persistent root DtDefinition for this fragment
      Returns:
      this builder
    • withStereoType

      public DataDefinitionBuilder withStereoType(DataStereotype stereotype)
      Sets the stereotype of the dataDefinition.
      Parameters:
      stereotype - the stereotype of the dataDefinition
      Returns:
      this builder
    • addForeignKey

      public DataDefinitionBuilder addForeignKey(String fieldName, String label, SmartTypeDefinition domain, io.vertigo.core.lang.Cardinality cardinality, String fkDtDefinitionName)
      Adds a field linked to another dataDefinition (aka foreign key).
      Parameters:
      fieldName - the name of the field
      label - the label of the field
      cardinality - cardinality of the field see Cardinality
      fkDtDefinitionName - the name of the linked definition
      smartType - the smartType of the field
      required - if the field is required
      Returns:
      this builder
    • addComputedField

      public DataDefinitionBuilder addComputedField(String fieldName, String label, SmartTypeDefinition smartType, io.vertigo.core.lang.Cardinality cardinality)
      Adds a computed field.
      Parameters:
      fieldName - the name of the field
      label - the label of the field
      smartType - the smartType of the field
      cardinality - cardinality of the field see Cardinality
      Returns:
      this builder
    • addDataField

      public DataDefinitionBuilder addDataField(String fieldName, String label, SmartTypeDefinition domain, io.vertigo.core.lang.Cardinality cardinality, boolean persistent)
      Adds a common data field.
      Parameters:
      fieldName - the name of the field
      label - the label of the field
      cardinality - cardinality of the field see Cardinality
      persistent - if the fiels is persistent
      smartType - the smartType of the field
      required - if the field is required
      Returns:
      this builder
    • addIdField

      public DataDefinitionBuilder addIdField(String fieldName, String label, SmartTypeDefinition domain)
      Adds an ID field. This field is required.
      Parameters:
      fieldName - the name of the field
      label - the label of the field
      smartType - the smartType of the field
      Returns:
      this builder
    • withDataSpace

      public DataDefinitionBuilder withDataSpace(String dataSpace)
      Sets the dataSpace to which the dataDefinition belongs.
      Parameters:
      dataSpace - the dataSpace to which the DataDefinition is mapped.
      Returns:
      this builder
    • withSortField

      public DataDefinitionBuilder withSortField(String sortFieldName)
      Specifies which field to be used for sorting
      Parameters:
      sortFieldName - fieldName to use
      Returns:
      this builder
    • withDisplayField

      public DataDefinitionBuilder withDisplayField(String displayFieldName)
      Specifies which field to be used for display
      Parameters:
      displayFieldName - fieldName to use
      Returns:
      this builder
    • withHandleField

      public DataDefinitionBuilder withHandleField(String handleFieldName)
      Specifies which field to be used for handle
      Parameters:
      handleFieldName - fieldName to use
      Returns:
      this builder
    • withKeyField

      public DataDefinitionBuilder withKeyField(String keyFieldName)
      Specifies which field to be used to distinguish elements inside a collection
      Parameters:
      keyFieldName - fieldName to use
      Returns:
      this builder
    • build

      public DataDefinition build()
      Specified by:
      build in interface io.vertigo.core.lang.Builder<DataDefinition>