Class EntityModelImpl
java.lang.Object
ch.tocco.nice2.model.entity.api.DefaultModelBase
ch.tocco.nice2.model.entity.api.DefaultEntityModel
ch.tocco.nice2.model.entity.impl.entity.EntityModelImpl
- All Implemented Interfaces:
NiceActionHolder
,EntityModel
,ModelElement
,ModuleTracker
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAvailableLocale
(Locale locale) void
addDocumentation
(String definingModule, String documentation) Adds documentation for theEntityModel
, contributed by the definingAppModule
.void
addExtendingModule
(String moduleName) final void
addField
(FieldModel niceField) Adds a field to this entity model.void
addRelation
(RelationModel relation) void
addSearch
(EntitySearchModel search) Adds anotherEntitySearchModel
to thisEntityModel
.@Nullable ActionsModel
Returns the name of the nice2 module, where this model element is defined.Returns the content of the documentation element of theEntityModel
tag as aLinkedHashMap
, divided by theAppModule
s extending the baseEntityModel
and contributing the documentation.Returns a list of nice2 module names, that have contributed to this model element.@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) 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'.@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.@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
@Nullable Boolean
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
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) void
setActions
(ActionsModel actions) void
setBusinessUnitType
(BusinessUnitType businessUnitType) void
setContentReference
(Boolean contentReference) Specify whether this entity can be a content reference source.void
setDefiningModule
(String name) void
setEntityDocumentsModel
(EntityDocumentsModel entityDocumentsModel) void
setHasExportAction
(Boolean hasExportAction) void
setHasGenericActions
(Boolean hasGenericActions) void
setHasImportAction
(Boolean hasImportAction) void
setIndexPriority
(Integer indexPriority) void
setMarkable
(Boolean markable) void
setOutputCenter
(boolean outputCenter) void
setRelevantForExport
(Boolean relevantForExport) void
setUseAdminCreate
(Boolean useAdminCreate) void
setUseAdminDelete
(Boolean useAdminDelete) void
setUseEntityMergeAction
(Boolean useEntityMergeAction) void
setUseHistoryAction
(Boolean useHistoryAction) 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 class ch.tocco.nice2.model.entity.api.DefaultEntityModel
getEntityType, getFieldsByBaseType, getFieldsByType, getFieldsNames, getFieldsTargets, getFirstFieldOfBaseType, getFirstFieldOfType, getName, getTarget, hasField, hasRelation, isDisabled, setDisabled, setEntityType, setName, setTarget
Methods inherited from class ch.tocco.nice2.model.entity.api.DefaultModelBase
getAdditionalToStringInfo, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.model.entity.api.EntityModel
getEntityType, getFieldsByBaseType, getFieldsByType, getFieldsNames, getFieldsTargets, getFirstFieldOfBaseType, getFirstFieldOfType, getName, getTarget, hasField, hasRelation, isDisabled, requireFieldByName, requireRelationByName, setDisabled, setEntityType, setName, setTarget
-
Constructor Details
-
EntityModelImpl
public EntityModelImpl()
-
-
Method Details
-
getExtendingModules
Description copied from interface:ModuleTracker
Returns a list of nice2 module names, that have contributed to this model element.- Specified by:
getExtendingModules
in interfaceModuleTracker
-
addExtendingModule
- Specified by:
addExtendingModule
in interfaceModuleTracker
-
getDocumentation
Description copied from interface:EntityModel
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.- Specified by:
getDocumentation
in interfaceEntityModel
- Returns:
- The
LinkedHashMap
contains theEntityModel
's documentation tag.
-
addDocumentation
Description copied from interface:EntityModel
Adds documentation for theEntityModel
, contributed by the definingAppModule
.- Specified by:
addDocumentation
in interfaceEntityModel
- Parameters:
definingModule
- the string representation of theAppModule
contributing the documentationdocumentation
- the documentation for theEntityModel
-
getDefiningModule
Description copied from interface:ModuleTracker
Returns the name of the nice2 module, where this model element is defined.- Specified by:
getDefiningModule
in interfaceModuleTracker
-
setDefiningModule
- Specified by:
setDefiningModule
in interfaceModuleTracker
-
addField
Description copied from class:DefaultEntityModel
Adds a field to this entity model.WARNING: This implementation currently does not check for duplicates, or fields with the same name. This is currently left up to you, but might change in the future.
- Specified by:
addField
in interfaceEntityModel
- Overrides:
addField
in classDefaultEntityModel
- Parameters:
niceField
- The field to add.- Throws:
IllegalArgumentException
- (unknown nice-field, unsupported property in nice-field)
-
getKey
- Specified by:
getKey
in interfaceEntityModel
- Overrides:
getKey
in classDefaultEntityModel
- Returns:
- The primary key field.
-
getFields
- Specified by:
getFields
in interfaceEntityModel
- Overrides:
getFields
in classDefaultEntityModel
- Returns:
- The fields including those part of the primary keys (see
EntityModel.getKey()
).
-
getLocalizedFieldMapper
- Specified by:
getLocalizedFieldMapper
in interfaceEntityModel
-
getFieldByName
Description copied from interface:EntityModel
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".- Specified by:
getFieldByName
in interfaceEntityModel
- Overrides:
getFieldByName
in classDefaultEntityModel
- 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:
-
getFieldByName
Description copied from interface:EntityModel
Get a possibly multilingual field by base name and locale.This is a shortcut for doing:
EntityModel.getFieldByName( EntityModel.getLocalizedFieldMapper().getFieldName(name, locale) );
- Specified by:
getFieldByName
in interfaceEntityModel
- 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
- Specified by:
getFieldByName
in interfaceEntityModel
-
addAvailableLocale
- Specified by:
addAvailableLocale
in interfaceEntityModel
-
getAvailableLocales
- Specified by:
getAvailableLocales
in interfaceEntityModel
-
isLocalizedField
Description copied from interface:EntityModel
Tells if there is a localized field with the given base name.- Specified by:
isLocalizedField
in interfaceEntityModel
- 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
Description copied from interface:EntityModel
Returns all field models (one per system language) for the field that is of type 'localized'.- Specified by:
getLocalizedFields
in interfaceEntityModel
- 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
Description copied from interface:EntityModel
Returns one field model for the field that is of type 'localized'.- Specified by:
getLocalizedField
in interfaceEntityModel
- 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:
-
getRelations
Description copied from interface:EntityModel
Get all relations FROM this entity TO other entities; only one way. There seems to be no method for the opposite yet.- Specified by:
getRelations
in interfaceEntityModel
- Overrides:
getRelations
in classDefaultEntityModel
-
getRemovedFields
Description copied from interface:EntityModel
Returns all removed field models. Returns an empty collection if none exist.- Specified by:
getRemovedFields
in interfaceEntityModel
-
hasRemovedField
Description copied from interface:EntityModel
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.- Specified by:
hasRemovedField
in interfaceEntityModel
- Parameters:
name
- the name- Returns:
- true if this field got removed during the configuration-reading-process
-
getRemovedRelations
Description copied from interface:EntityModel
Returns all removed field models. Returns an empty collection if none exist.- Specified by:
getRemovedRelations
in interfaceEntityModel
-
hasRemovedRelation
Description copied from interface:EntityModel
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.- Specified by:
hasRemovedRelation
in interfaceEntityModel
- Parameters:
name
- the name- Returns:
- true if this field got removed during the configuration-reading-process
-
addRelation
- Specified by:
addRelation
in interfaceEntityModel
- Overrides:
addRelation
in classDefaultEntityModel
- Parameters:
relation
- The relation.- See Also:
-
replaceRelation
- Specified by:
replaceRelation
in interfaceEntityModel
- See Also:
-
getRelationByName
Description copied from interface:EntityModel
Get a relation by its name.- Specified by:
getRelationByName
in interfaceEntityModel
- Overrides:
getRelationByName
in classDefaultEntityModel
- Parameters:
name
- The name.- Returns:
- The relation or null if this relation doesn't exists!
-
getVisualisation
Description copied from interface:EntityModel
Get an object which describes the visualisation of this entity.- Specified by:
getVisualisation
in interfaceEntityModel
- Returns:
- The visualisation.
-
setVisualisation
- Specified by:
setVisualisation
in interfaceEntityModel
-
getSearch
Description copied from interface:EntityModel
Get a description for how to search in this entity.- Specified by:
getSearch
in interfaceEntityModel
- Returns:
- The search behavior.
-
addSearch
Description copied from interface:EntityModel
Adds anotherEntitySearchModel
to thisEntityModel
.- Specified by:
addSearch
in interfaceEntityModel
- Parameters:
search
- The search model.
-
getActions
- Specified by:
getActions
in interfaceNiceActionHolder
-
setActions
- Specified by:
setActions
in interfaceNiceActionHolder
-
removeField
- Specified by:
removeField
in interfaceEntityModel
- 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
- Specified by:
removeRelation
in interfaceEntityModel
- Parameters:
toRemove
- the field to remove
-
setUseMassMutationActions
- Specified by:
setUseMassMutationActions
in interfaceEntityModel
-
getUseMassMutationActions
- Specified by:
getUseMassMutationActions
in interfaceEntityModel
-
setUseHistoryAction
- Specified by:
setUseHistoryAction
in interfaceEntityModel
-
getUseHistoryAction
- Specified by:
getUseHistoryAction
in interfaceEntityModel
-
setUseEntityMergeAction
- Specified by:
setUseEntityMergeAction
in interfaceEntityModel
-
getUseEntityMergeAction
- Specified by:
getUseEntityMergeAction
in interfaceEntityModel
-
setHasImportAction
- Specified by:
setHasImportAction
in interfaceEntityModel
-
hasImportAction
- Specified by:
hasImportAction
in interfaceEntityModel
-
setHasExportAction
- Specified by:
setHasExportAction
in interfaceEntityModel
-
hasExportAction
- Specified by:
hasExportAction
in interfaceEntityModel
-
setUseAdminCreate
- Specified by:
setUseAdminCreate
in interfaceEntityModel
-
getUseAdminCreate
- Specified by:
getUseAdminCreate
in interfaceEntityModel
-
setUseAdminDelete
- Specified by:
setUseAdminDelete
in interfaceEntityModel
-
getUseAdminDelete
- Specified by:
getUseAdminDelete
in interfaceEntityModel
-
setUseRemoteFieldNewButton
- Specified by:
setUseRemoteFieldNewButton
in interfaceEntityModel
-
getUseRemoteFieldNewButton
- Specified by:
getUseRemoteFieldNewButton
in interfaceEntityModel
-
setRelevantForExport
- Specified by:
setRelevantForExport
in interfaceEntityModel
-
getRelevantForExport
- Specified by:
getRelevantForExport
in interfaceEntityModel
-
hasGenericActions
- Specified by:
hasGenericActions
in interfaceEntityModel
-
setHasGenericActions
- Specified by:
setHasGenericActions
in interfaceEntityModel
-
isMarkable
- Specified by:
isMarkable
in interfaceEntityModel
-
setMarkable
- Specified by:
setMarkable
in interfaceEntityModel
-
getUseNiceFields
- Specified by:
getUseNiceFields
in interfaceEntityModel
-
setUseNiceFields
- Specified by:
setUseNiceFields
in interfaceEntityModel
-
getEntityDocumentsModel
- Specified by:
getEntityDocumentsModel
in interfaceEntityModel
-
setEntityDocumentsModel
- Specified by:
setEntityDocumentsModel
in interfaceEntityModel
-
isOutputCenter
public boolean isOutputCenter()- Specified by:
isOutputCenter
in interfaceEntityModel
-
setOutputCenter
public void setOutputCenter(boolean outputCenter) - Specified by:
setOutputCenter
in interfaceEntityModel
-
getIndexPriority
Description copied from interface:EntityModel
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- Specified by:
getIndexPriority
in interfaceEntityModel
-
setIndexPriority
- Specified by:
setIndexPriority
in interfaceEntityModel
- See Also:
-
getBusinessUnitType
- Specified by:
getBusinessUnitType
in interfaceEntityModel
-
setBusinessUnitType
- Specified by:
setBusinessUnitType
in interfaceEntityModel
-
getWidgetEntityType
Description copied from interface:EntityModel
Get the entity widget entity type (CMS).- Specified by:
getWidgetEntityType
in interfaceEntityModel
- Returns:
- the widget entity type.
-
setWidgetEntityType
Description copied from interface:EntityModel
Set widget entity type (CMS).- Specified by:
setWidgetEntityType
in interfaceEntityModel
- Parameters:
widgetEntityType
- The widget entity type.
-
hasContentReference
Description copied from interface:EntityModel
Determine whether this entity can be a content reference source.- Specified by:
hasContentReference
in interfaceEntityModel
- Returns:
- true, if the entity can be a content reference source, else false.
-
setContentReference
Description copied from interface:EntityModel
Specify whether this entity can be a content reference source.- Specified by:
setContentReference
in interfaceEntityModel
-