Package ch.tocco.nice2.model.entity.api
Class DefaultEntityModel
java.lang.Object
ch.tocco.nice2.model.entity.api.DefaultModelBase
ch.tocco.nice2.model.entity.api.DefaultEntityModel
- All Implemented Interfaces:
NiceActionHolder
,EntityModel
,ModelElement
,ModuleTracker
- Direct Known Subclasses:
EntityModelImpl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a field to this entity model.void
addRelation
(RelationModel relation) @Nullable FieldModel
getFieldByName
(String name) Get a field by its name.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 ...getKey()
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.It's the "target" attribute of the entityModel tag.boolean
Included are key fields, but not relations.boolean
hasRelation
(String relName) boolean
void
setDisabled
(boolean disabled) Sets if this entity is disabled and thus ignored.void
setEntityType
(EntityType entityType) void
void
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
addAvailableLocale, addDocumentation, addSearch, getAvailableLocales, getBusinessUnitType, getDocumentation, getEntityDocumentsModel, getFieldByName, getFieldByName, getIndexPriority, getLocalizedField, getLocalizedFieldMapper, getLocalizedFields, getRelevantForExport, getRemovedFields, getRemovedRelations, getSearch, getUseAdminCreate, getUseAdminDelete, getUseEntityMergeAction, getUseHistoryAction, getUseMassMutationActions, getUseNiceFields, getUseRemoteFieldNewButton, getVisualisation, getWidgetEntityType, hasContentReference, hasExportAction, hasGenericActions, hasImportAction, hasRemovedField, hasRemovedRelation, isLocalizedField, isMarkable, isOutputCenter, removeField, removeRelation, replaceRelation, requireFieldByName, requireRelationByName, setBusinessUnitType, setContentReference, setEntityDocumentsModel, setHasExportAction, setHasGenericActions, setHasImportAction, setIndexPriority, setMarkable, setOutputCenter, setRelevantForExport, setUseAdminCreate, setUseAdminDelete, setUseEntityMergeAction, setUseHistoryAction, setUseMassMutationActions, setUseNiceFields, setUseRemoteFieldNewButton, setVisualisation, setWidgetEntityType
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
-
Constructor Details
-
DefaultEntityModel
public DefaultEntityModel()
-
-
Method Details
-
getName
Description copied from interface:EntityModel
It's the "name" attribute of the entityModel tag.- Specified by:
getName
in interfaceEntityModel
- Overrides:
getName
in classDefaultModelBase
- Returns:
- The entity name of this entity, for example "Address".
-
setName
- Specified by:
setName
in interfaceEntityModel
- Overrides:
setName
in classDefaultModelBase
- Parameters:
name
- the name, non-null
-
isDisabled
public boolean isDisabled()- Specified by:
isDisabled
in interfaceEntityModel
- Returns:
- Tells if this entity is disabled and thus ignored.
-
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
-
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.
-
setTarget
- Specified by:
setTarget
in interfaceEntityModel
- Parameters:
target
- targent-name, non-null
-
setEntityType
- Specified by:
setEntityType
in interfaceEntityModel
- Parameters:
entityType
- The type of entity.
-
getEntityType
- Specified by:
getEntityType
in interfaceEntityModel
- Returns:
- The entity type.
-
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()
).
-
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:
-
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.
-
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.
-
addField
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
- Parameters:
f
- The field- Throws:
IllegalArgumentException
-
addRelation
- Specified by:
addRelation
in interfaceEntityModel
- Parameters:
relation
- The relation.- 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
-
getRelationByName
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!
-
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:
-