Package ch.tocco.nice2.model.entity.api
Interface EntityModel
- All Superinterfaces:
ModelElement
,ModuleTracker
,NiceActionHolder
- All Known Implementing Classes:
DefaultEntityModel
,EntityModelImpl
,TemplateEntityModel
The model for the data-mapping, but with addional information for the nice-system.
State
The state-behavior is likeModelElement
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAvailableLocale
(Locale locale) void
addDocumentation
(String definingModule, String documentation) Adds documentation for theEntityModel
, contributed by the definingAppModule
.void
addField
(FieldModel fieldModel) Adds a nice-field to this entity model.void
addRelation
(RelationModel relation) void
addSearch
(EntitySearchModel search) Adds anotherEntitySearchModel
to thisEntityModel
.Returns the content of the documentation element of theEntityModel
tag as aLinkedHashMap
, divided by theAppModule
s extending the baseEntityModel
and contributing the documentation.@Nullable FieldModel
getFieldByName
(String name) Get a field by its name.@Nullable FieldModel
getFieldByName
(String name, String locale) Get a possibly multilingual field by base name and locale.@Nullable FieldModel
getFieldByName
(String name, Locale locale) getFieldsByBaseType
(String baseType) Returns all fields that have the specified data type as base type.getFieldsByType
(String type) Returns all fields of the data type specified.getFieldsNames
(List<FieldModel> fields) Example: myEntityModel.getFieldsNames( myEntityModel.getKeys() )getFieldsTargets
(List<FieldModel> fields) Example: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )@Nullable FieldModel
getFirstFieldOfBaseType
(String baseType) @Nullable FieldModel
getFirstFieldOfType
(String type) version, createts, updateuser ...Will be used as order for indexing entities.getKey()
@Nullable FieldModel
getLocalizedField
(String baseName, Locale locale) Returns one field model for the field that is of type 'localized'.getLocalizedFields
(String baseName) Returns all field models (one per system language) for the field that is of type 'localized'.getName()
It's the "name" attribute of the entityModel tag.@Nullable RelationModel
getRelationByName
(String name) Get a relation by its name.Get all relations FROM this entity TO other entities; only one way.Returns all removed field models.Returns all removed field models.Get a description for how to search in this entity.It's the "target" attribute of the entityModel tag.@Nullable Boolean
@Nullable Boolean
@Nullable Boolean
Get an object which describes the visualisation of this entity.Get the entity widget entity type (CMS).Determine whether this entity can be a content reference source.@Nullable Boolean
boolean
Included are key fields, but not relations.@Nullable Boolean
@Nullable Boolean
boolean
hasRelation
(String relName) boolean
hasRemovedField
(String name) Does this Entity-Model contain a removed field?
A possibility to ask the configuration if something got removed.boolean
hasRemovedRelation
(String name) Does this Entity-Model contain a removed relation?
A possibility to ask the configuration if something got removed.boolean
boolean
isLocalizedField
(String baseName) Tells if there is a localized field with the given base name.boolean
void
removeField
(FieldModel toRemove) void
removeRelation
(RelationModel toRemove) void
replaceRelation
(RelationModel relation) default FieldModel
requireFieldByName
(String name) Get a field by its name.default RelationModel
requireRelationByName
(String name) Get a relation by its name.void
void
setContentReference
(Boolean contentReference) Specify whether this entity can be a content reference source.void
setDisabled
(boolean disabled) Sets if this entity is disabled and thus ignored.void
setEntityDocumentsModel
(EntityDocumentsModel entityDocumentsModel) void
setEntityType
(EntityType entityType) void
setHasExportAction
(Boolean hasExportAction) void
setHasGenericActions
(Boolean hasGenericActions) void
setHasImportAction
(Boolean hasImportAction) void
setIndexPriority
(Integer indexPriority) void
setMarkable
(Boolean markable) void
void
setOutputCenter
(boolean outputCenter) void
setRelevantForExport
(Boolean relevantForExport) void
void
setUseAdminCreate
(Boolean useAdminCreate) void
setUseAdminDelete
(Boolean useAdminDelete) void
setUseEntityMergeAction
(Boolean useEntityMergeAction) void
setUseHistoryAction
(Boolean useMassMutationAction) void
setUseMassMutationActions
(Boolean useMassMutationActions) void
setUseNiceFields
(Boolean useNiceFields) void
setUseRemoteFieldNewButton
(Boolean useRemoteFieldNewButton) void
setVisualisation
(EntityVisualisationModel visualisation) void
setWidgetEntityType
(WidgetEntityType widgetEntityType) Set widget entity type (CMS).Methods inherited from interface ch.tocco.nice2.model.entity.api.ModuleTracker
addExtendingModule, getDefiningModule, getExtendingModules, setDefiningModule
Methods inherited from interface ch.tocco.nice2.model.base.api.actions.NiceActionHolder
getActions, setActions
-
Method Details
-
getName
String getName()It's the "name" attribute of the entityModel tag.- Returns:
- The entity name of this entity, for example "Address".
-
getTarget
String getTarget()It's the "target" attribute of the entityModel tag.- Returns:
- The internal target of this entity, eg the table name.
-
getEntityType
EntityType getEntityType()- Returns:
- The entity type.
-
isDisabled
boolean isDisabled()- Returns:
- Tells if this entity is disabled and thus ignored.
-
setDisabled
void setDisabled(boolean disabled) Sets if this entity is disabled and thus ignored.- Parameters:
disabled
- if disabled
-
getKey
FieldModel getKey()- Returns:
- The primary key field.
-
getFieldsTargets
Example: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )- Parameters:
fields
- The fields to loop.- Returns:
- The targets of the passed in fields.
-
getFieldsNames
Example: myEntityModel.getFieldsNames( myEntityModel.getKeys() )- Parameters:
fields
- The fields to loop.- Returns:
- The names of the passed in fields.
-
getFields
List<FieldModel> getFields()- Returns:
- The fields including those part of the primary keys (see
getKey()
).
-
hasField
Included are key fields, but not relations.- Parameters:
fieldName
- The field name to look for.- Returns:
- Tells if this model has a field by that name.
- See Also:
-
getFieldByName
Get a field by its name. Note: If the field is multilingual then provide the complete name for the strategy in use, which may look something like "somename" or "somename_fr".- Parameters:
name
- The complete field's name (including possible localized suffix), not empty.- Returns:
- The field, or
null
if this field doesn't exists! - See Also:
-
requireFieldByName
Get a field by its name.- Parameters:
name
- The field's name, not empty.- Throws:
ModelException
- If there is no such field.- See Also:
-
getFieldsByType
Returns all fields of the data type specified.- Returns:
- May be empty.
-
getFieldsByBaseType
Returns all fields that have the specified data type as base type.- Returns:
- May be empty.
-
getFirstFieldOfType
version, createts, updateuser ...- Returns:
- The first field as returned by getFieldsByType(), or null.
-
getFirstFieldOfBaseType
- Returns:
- The first field as returned by getFieldsByBaseType(), or null.
-
getRelations
Collection<RelationModel> getRelations()Get all relations FROM this entity TO other entities; only one way. There seems to be no method for the opposite yet. -
getRelationByName
Get a relation by its name.- Parameters:
name
- The name.- Returns:
- The relation or null if this relation doesn't exists!
-
requireRelationByName
Get a relation by its name.- Throws:
ModelException
- If there is no such relation.- See Also:
-
hasRelation
- Parameters:
relName
- The relation name to look for, eg "relFoo".- Returns:
- Tells if this model has a relation by that name.
- See Also:
-
setTarget
- Parameters:
target
- targent-name, non-null- Throws:
IllegalStateException
- when trying to change the model after finished model-reading
-
setEntityType
- Parameters:
entityType
- The type of entity.- Throws:
IllegalStateException
- when trying to change the model after finished model-reading
-
addField
Adds a nice-field to this entity model. WARNING: All key fields need to be added first! If you try to add a regular field first then you'll get a strange ClassCastException to Long. Note: a field "removed" (disabled) by removeField() cannot be re-added here.- Parameters:
fieldModel
- The field model- Throws:
IllegalArgumentException
-
addRelation
- Parameters:
relation
- The relation.- Throws:
IllegalStateException
- When trying to change the model after finished model-reading. Or when there is such a relation already.- See Also:
-
setName
- Parameters:
name
- the name, non-null- Throws:
IllegalStateException
- when trying to change the model after finished model-reading
-
getDocumentation
LinkedHashMap<String,String> getDocumentation()Returns the content of the documentation element of theEntityModel
tag as aLinkedHashMap
, divided by theAppModule
s extending the baseEntityModel
and contributing the documentation. The contents of the map are ordered according to the loading sequence of theAppModule
s.- Returns:
- The
LinkedHashMap
contains theEntityModel
's documentation tag.
-
addDocumentation
Adds documentation for theEntityModel
, contributed by the definingAppModule
.- Parameters:
definingModule
- the string representation of theAppModule
contributing the documentationdocumentation
- the documentation for theEntityModel
-
getFieldByName
Get a possibly multilingual field by base name and locale.This is a shortcut for doing:
EntityModel.getFieldByName( EntityModel.getLocalizedFieldMapper().getFieldName(name, locale) );
- Parameters:
name
- The field's base name, not empty.locale
- Currently the 2-digit lowercase ISO-639 language code only, eg "fr" for French.- Returns:
- The field, or
null
if this field doesn't exists (either at all or in that locale) - See Also:
-
getFieldByName
-
isLocalizedField
Tells if there is a localized field with the given base name.- Parameters:
baseName
- The field's base name as specified in the entity xml file, without language part.- Returns:
true
If there is such a field and it is a localized one,false
if there is no such field at all, or if it is not localized.- See Also:
-
getLocalizedFields
Returns all field models (one per system language) for the field that is of type 'localized'.- Parameters:
baseName
- The field's base name as specified in the entity xml file, without language part.- Returns:
- key = 2 letter iso language code in lower case. Not empty, no null values within.
- Throws:
IllegalArgumentException
- If the field is not localized,check first
.- See Also:
-
getLocalizedField
Returns one field model for the field that is of type 'localized'.- Parameters:
baseName
- The field's base name as specified in the entity xml file, without language part.locale
- The desired language, must be one of the configured system languages (2 letter lower case iso code).- Returns:
null
if there is no such field, or if it is not localized, or if there is no such language.- See Also:
-
addAvailableLocale
-
getAvailableLocales
-
getLocalizedFieldMapper
LocalizedFieldMapper getLocalizedFieldMapper() -
hasRemovedField
Does this Entity-Model contain a removed field?
A possibility to ask the configuration if something got removed. This is imported to remove dependent stuff.
For example the field 'username' is removed on an entity. The form-system needs to know that this field is removed that the field is also removed in the form.- Parameters:
name
- the name- Returns:
- true if this field got removed during the configuration-reading-process
-
getRemovedFields
Collection<FieldModel> getRemovedFields()Returns all removed field models. Returns an empty collection if none exist. -
hasRemovedRelation
Does this Entity-Model contain a removed relation?
A possibility to ask the configuration if something got removed. This is importet to remove dependend stuff.
For example we remove the Field 'username' on an entity. Then the form-system need to know that this it's removed explictly and no spelling-error in the form-configuration. Then the form-system can remove the field aswell which would normally show this entity-field.- Parameters:
name
- the name- Returns:
- true if this field got removed during the configuration-reading-process
-
getRemovedRelations
Collection<RelationModel> getRemovedRelations()Returns all removed field models. Returns an empty collection if none exist. -
replaceRelation
- Throws:
IllegalStateException
- When trying to change the model after finished model-reading. Or when there is no such a relation yet.- See Also:
-
getVisualisation
EntityVisualisationModel getVisualisation()Get an object which describes the visualisation of this entity.- Returns:
- The visualisation.
-
setVisualisation
- Throws:
IllegalStateException
- When trying to change the model after finished model-reading.
-
getSearch
EntitySearchModel getSearch()Get a description for how to search in this entity.- Returns:
- The search behavior.
-
addSearch
Adds anotherEntitySearchModel
to thisEntityModel
.- Parameters:
search
- The search model.- Throws:
IllegalStateException
- when try to change the model after finished model-reading
-
removeField
- Parameters:
toRemove
- the field to remove- Throws:
IllegalStateException
- when try to change the model after finished model-readingIllegalArgumentException
- when the field is not removable (not there)
-
removeRelation
- Parameters:
toRemove
- the field to remove- Throws:
IllegalStateException
- When trying to change the model after finished model-reading.
-
setUseMassMutationActions
-
getUseMassMutationActions
-
setHasGenericActions
-
hasGenericActions
-
setUseHistoryAction
-
getUseHistoryAction
-
setUseEntityMergeAction
-
getUseEntityMergeAction
-
setHasImportAction
-
hasImportAction
-
setHasExportAction
-
hasExportAction
-
setUseAdminCreate
-
getUseAdminCreate
Boolean getUseAdminCreate() -
setUseAdminDelete
-
getUseAdminDelete
Boolean getUseAdminDelete() -
setUseRemoteFieldNewButton
-
getUseRemoteFieldNewButton
Boolean getUseRemoteFieldNewButton() -
setRelevantForExport
-
getRelevantForExport
Boolean getRelevantForExport() -
isMarkable
Boolean isMarkable() -
setMarkable
-
getUseNiceFields
Boolean getUseNiceFields() -
setUseNiceFields
-
getIndexPriority
Integer getIndexPriority()Will be used as order for indexing entities. Also describes order when displaying results (higher value is higher in list). Possible values: * -1: not indexed * 0: indexed, but not visible in searching in "full-system-search". used for lookup entities for example. * 1..n: indexed -
setIndexPriority
- See Also:
-
setBusinessUnitType
-
getBusinessUnitType
BusinessUnitType getBusinessUnitType() -
getEntityDocumentsModel
EntityDocumentsModel getEntityDocumentsModel() -
setEntityDocumentsModel
-
isOutputCenter
boolean isOutputCenter() -
setOutputCenter
void setOutputCenter(boolean outputCenter) -
getWidgetEntityType
WidgetEntityType getWidgetEntityType()Get the entity widget entity type (CMS).- Returns:
- the widget entity type.
-
setWidgetEntityType
Set widget entity type (CMS).- Parameters:
widgetEntityType
- The widget entity type.
-
hasContentReference
Boolean hasContentReference()Determine whether this entity can be a content reference source.- Returns:
- true, if the entity can be a content reference source, else false.
-
setContentReference
Specify whether this entity can be a content reference source.
-