Class TemplateEntityModel
java.lang.Object
ch.tocco.nice2.persist.entity.spi.template.TemplateEntityModel
- All Implemented Interfaces:
NiceActionHolder
,EntityModel
,ModelElement
,ModuleTracker
-
Field Summary
Modifier and TypeFieldDescriptionprotected final EntityModel
static final Predicate
<FieldModel> static final Predicate
<FieldModel> static final Predicate
<FieldModel> static final String
-
Constructor Summary
ConstructorDescriptionTemplateEntityModel
(EntityModel baseEntityModel, EntityModel entityTemplateModel) -
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) void
addField
(FieldModel field) Adds a nice-field to this entity model.void
addRelation
(RelationModel relation) void
addSearch
(EntitySearchModel search) Adds anotherEntitySearchModel
to thisEntityModel
.boolean
@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) 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 ...Collection
<ch.tocco.nice2.persist.entity.spi.template.ForwardingRelationModel> 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 ch.tocco.nice2.persist.entity.spi.template.ForwardingRelationModel
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.Returns only those fields of the base entity that belong to the template (i.e.@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
int
hashCode()
@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) void
setActions
(ActionsModel actions) void
void
setContentReference
(Boolean contentReference) Specify whether this entity can be a content reference source.void
setDefiningModule
(String moduleName) 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).toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.model.entity.api.EntityModel
requireFieldByName, requireRelationByName
-
Field Details
-
TEMPLATE_FIELD_PREFIX
- See Also:
-
noKeys
-
noLocalizedBaseFields
-
noXmlData
-
baseEntityModel
-
-
Constructor Details
-
TemplateEntityModel
-
-
Method Details
-
getName
Description copied from interface:EntityModel
It's the "name" attribute of the entityModel tag.- Specified by:
getName
in interfaceEntityModel
- Returns:
- The entity name of this entity, for example "Address".
-
getBaseModel
-
getEntityTemplateModel
-
getRelationByName
@Nullable public @Nullable ch.tocco.nice2.persist.entity.spi.template.ForwardingRelationModel getRelationByName(String name) Description copied from interface:EntityModel
Get a relation by its name.- Specified by:
getRelationByName
in interfaceEntityModel
- Parameters:
name
- The name.- Returns:
- The relation or null if this relation doesn't exists!
-
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
-
getForwardRelations
public Collection<ch.tocco.nice2.persist.entity.spi.template.ForwardingRelationModel> getForwardRelations() -
getKey
- Specified by:
getKey
in interfaceEntityModel
- Returns:
- The primary key field.
-
getFields
- Specified by:
getFields
in interfaceEntityModel
- Returns:
- The fields including those part of the primary keys (see
EntityModel.getKey()
).
-
getTemplateFields
Returns only those fields of the base entity that belong to the template (i.e. without the primary key of the base entity). -
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
- 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:
-
getFieldsByType
Description copied from interface:EntityModel
Returns all fields of the data type specified.- Specified by:
getFieldsByType
in interfaceEntityModel
- Returns:
- May be empty.
-
getFieldsByBaseType
Description copied from interface:EntityModel
Returns all fields that have the specified data type as base type.- Specified by:
getFieldsByBaseType
in interfaceEntityModel
- Returns:
- May be empty.
-
getTarget
Description copied from interface:EntityModel
It's the "target" attribute of the entityModel tag.- Specified by:
getTarget
in interfaceEntityModel
- Returns:
- The internal target of this entity, eg the table name.
-
hasRelation
- Specified by:
hasRelation
in interfaceEntityModel
- Parameters:
relName
- The relation name to look for, eg "relFoo".- Returns:
- Tells if this model has a relation by that name.
- See Also:
-
toString
-
isMarkable
- Specified by:
isMarkable
in interfaceEntityModel
-
setMarkable
- Specified by:
setMarkable
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:
-
addRelation
- Specified by:
addRelation
in interfaceEntityModel
- Parameters:
relation
- The relation.- See Also:
-
replaceRelation
- Specified by:
replaceRelation
in interfaceEntityModel
- See Also:
-
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
-
setUseHistoryAction
- Specified by:
setUseHistoryAction
in interfaceEntityModel
-
setUseEntityMergeAction
- Specified by:
setUseEntityMergeAction
in interfaceEntityModel
-
setUseAdminCreate
- Specified by:
setUseAdminCreate
in interfaceEntityModel
-
setUseAdminDelete
- Specified by:
setUseAdminDelete
in interfaceEntityModel
-
setUseRemoteFieldNewButton
- Specified by:
setUseRemoteFieldNewButton
in interfaceEntityModel
-
setRelevantForExport
- Specified by:
setRelevantForExport
in interfaceEntityModel
-
setDisabled
public void setDisabled(boolean disabled) Description copied from interface:EntityModel
Sets if this entity is disabled and thus ignored.- Specified by:
setDisabled
in interfaceEntityModel
- Parameters:
disabled
- if disabled
-
setTarget
- Specified by:
setTarget
in interfaceEntityModel
- Parameters:
target
- targent-name, non-null
-
setEntityType
- Specified by:
setEntityType
in interfaceEntityModel
- Parameters:
entityType
- The type of entity.
-
addField
Description copied from interface:EntityModel
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.- Specified by:
addField
in interfaceEntityModel
- Parameters:
field
- The field model
-
setName
- Specified by:
setName
in interfaceEntityModel
- Parameters:
name
- the name, non-null
-
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
-
setActions
- Specified by:
setActions
in interfaceNiceActionHolder
-
addExtendingModule
- Specified by:
addExtendingModule
in interfaceModuleTracker
-
setDefiningModule
- Specified by:
setDefiningModule
in interfaceModuleTracker
-
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
-
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:
-
addAvailableLocale
- Specified by:
addAvailableLocale
in interfaceEntityModel
-
getAvailableLocales
- Specified by:
getAvailableLocales
in interfaceEntityModel
-
getLocalizedFieldMapper
- Specified by:
getLocalizedFieldMapper
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
-
getRemovedFields
Description copied from interface:EntityModel
Returns all removed field models. Returns an empty collection if none exist.- Specified by:
getRemovedFields
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
-
getRemovedRelations
Description copied from interface:EntityModel
Returns all removed field models. Returns an empty collection if none exist.- Specified by:
getRemovedRelations
in interfaceEntityModel
-
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.
-
getUseMassMutationActions
- Specified by:
getUseMassMutationActions
in interfaceEntityModel
-
getUseHistoryAction
- Specified by:
getUseHistoryAction
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
-
getUseAdminCreate
- Specified by:
getUseAdminCreate
in interfaceEntityModel
-
getUseAdminDelete
- Specified by:
getUseAdminDelete
in interfaceEntityModel
-
getUseRemoteFieldNewButton
- Specified by:
getUseRemoteFieldNewButton
in interfaceEntityModel
-
getRelevantForExport
- Specified by:
getRelevantForExport
in interfaceEntityModel
-
setHasGenericActions
- Specified by:
setHasGenericActions
in interfaceEntityModel
-
hasGenericActions
- Specified by:
hasGenericActions
in interfaceEntityModel
-
getUseNiceFields
- Specified by:
getUseNiceFields
in interfaceEntityModel
-
setUseNiceFields
- Specified by:
setUseNiceFields
in interfaceEntityModel
-
setBusinessUnitType
- Specified by:
setBusinessUnitType
in interfaceEntityModel
-
getBusinessUnitType
- Specified by:
getBusinessUnitType
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
-
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
-
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.
-
getEntityType
- Specified by:
getEntityType
in interfaceEntityModel
- Returns:
- The entity type.
-
isDisabled
public boolean isDisabled()- Specified by:
isDisabled
in interfaceEntityModel
- Returns:
- Tells if this entity is disabled and thus ignored.
-
getFieldsTargets
Description copied from interface:EntityModel
Example: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )- Specified by:
getFieldsTargets
in interfaceEntityModel
- Parameters:
fields
- The fields to loop.- Returns:
- The targets of the passed in fields.
-
getFieldsNames
Description copied from interface:EntityModel
Example: myEntityModel.getFieldsNames( myEntityModel.getKeys() )- Specified by:
getFieldsNames
in interfaceEntityModel
- Parameters:
fields
- The fields to loop.- Returns:
- The names of the passed in fields.
-
hasField
Description copied from interface:EntityModel
Included are key fields, but not relations.- Specified by:
hasField
in interfaceEntityModel
- Parameters:
fieldName
- The field name to look for.- Returns:
- Tells if this model has a field by that name.
- See Also:
-
getFirstFieldOfType
Description copied from interface:EntityModel
version, createts, updateuser ...- Specified by:
getFirstFieldOfType
in interfaceEntityModel
- Returns:
- The first field as returned by getFieldsByType(), or null.
-
getFirstFieldOfBaseType
- Specified by:
getFirstFieldOfBaseType
in interfaceEntityModel
- Returns:
- The first field as returned by getFieldsByBaseType(), or null.
-
getActions
- Specified by:
getActions
in interfaceNiceActionHolder
-
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
-
getDefiningModule
Description copied from interface:ModuleTracker
Returns the name of the nice2 module, where this model element is defined.- Specified by:
getDefiningModule
in interfaceModuleTracker
-
equals
-
hashCode
public int hashCode()
-