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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a field to this entity model.voidaddRelation(RelationModel relation) @Nullable FieldModelgetFieldByName(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 FieldModelgetFirstFieldOfBaseType(String baseType) @Nullable FieldModelgetFirstFieldOfType(String type) version, createts, updateuser ...getKey()getName()It's the "name" attribute of the entityModel tag.@Nullable RelationModelgetRelationByName(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.booleanIncluded are key fields, but not relations.booleanhasRelation(String relName) booleanvoidsetDisabled(boolean disabled) Sets if this entity is disabled and thus ignored.voidsetEntityType(EntityType entityType) voidvoidMethods inherited from class ch.tocco.nice2.model.entity.api.DefaultModelBase
getAdditionalToStringInfo, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.tocco.nice2.model.entity.api.EntityModel
addAvailableLocale, addDocumentation, addSearch, getAvailableLocales, getBusinessUnitType, getDocumentation, getEntityDocumentsModel, getFieldByName, getFieldByName, getIndexPriority, getLabel, getLocalizedField, getLocalizedFieldMapper, getLocalizedFields, getRelevantForExport, getRemovedFields, getRemovedRelations, getSearch, getUseAdminCreate, getUseAdminDelete, getUseEntityMergeAction, getUseHistoryAction, getUseMassMutationActions, getUseNiceFields, getUseRemoteFieldNewButton, getVisualisation, getWidgetEntityType, hasContentReference, hasExportAction, hasGenericActions, hasImportAction, hasRemovedField, hasRemovedRelation, hasResetInitialvaluesAction, isLocalizedField, isMarkable, isOutputCenter, removeField, removeRelation, replaceRelation, requireFieldByName, requireRelationByName, setBusinessUnitType, setContentReference, setEntityDocumentsModel, setHasExportAction, setHasGenericActions, setHasImportAction, setIndexPriority, setMarkable, setOutputCenter, setRelevantForExport, setResetInitialvaluesAction, setUseAdminCreate, setUseAdminDelete, setUseEntityMergeAction, setUseHistoryAction, setUseMassMutationActions, setUseNiceFields, setUseRemoteFieldNewButton, setVisualisation, setWidgetEntityTypeMethods inherited from interface ch.tocco.nice2.model.entity.api.ModuleTracker
addExtendingModule, getDefiningModule, getExtendingModules, setDefiningModuleMethods 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:EntityModelIt's the "name" attribute of the entityModel tag.- Specified by:
getNamein interfaceEntityModel- Overrides:
getNamein classDefaultModelBase- Returns:
- The entity name of this entity, for example "Address".
-
setName
- Specified by:
setNamein interfaceEntityModel- Overrides:
setNamein classDefaultModelBase- Parameters:
name- the name, non-null
-
isDisabled
public boolean isDisabled()- Specified by:
isDisabledin interfaceEntityModel- Returns:
- Tells if this entity is disabled and thus ignored.
-
setDisabled
public void setDisabled(boolean disabled) Description copied from interface:EntityModelSets if this entity is disabled and thus ignored.- Specified by:
setDisabledin interfaceEntityModel- Parameters:
disabled- if disabled
-
getTarget
Description copied from interface:EntityModelIt's the "target" attribute of the entityModel tag.- Specified by:
getTargetin interfaceEntityModel- Returns:
- The internal target of this entity, eg the table name.
-
setTarget
- Specified by:
setTargetin interfaceEntityModel- Parameters:
target- targent-name, non-null
-
setEntityType
- Specified by:
setEntityTypein interfaceEntityModel- Parameters:
entityType- The type of entity.
-
getEntityType
- Specified by:
getEntityTypein interfaceEntityModel- Returns:
- The entity type.
-
getKey
- Specified by:
getKeyin interfaceEntityModel- Returns:
- The primary key field.
-
getFields
- Specified by:
getFieldsin interfaceEntityModel- Returns:
- The fields including those part of the primary keys (see
EntityModel.getKey()).
-
getFieldsTargets
Description copied from interface:EntityModelExample: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )- Specified by:
getFieldsTargetsin interfaceEntityModel- Parameters:
fields- The fields to loop.- Returns:
- The targets of the passed in fields.
-
getFieldsNames
Description copied from interface:EntityModelExample: myEntityModel.getFieldsNames( myEntityModel.getKeys() )- Specified by:
getFieldsNamesin interfaceEntityModel- Parameters:
fields- The fields to loop.- Returns:
- The names of the passed in fields.
-
hasField
Description copied from interface:EntityModelIncluded are key fields, but not relations.- Specified by:
hasFieldin 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:EntityModelGet 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:
getFieldByNamein interfaceEntityModel- Parameters:
name- The complete field's name (including possible localized suffix), not empty.- Returns:
- The field, or
nullif this field doesn't exists! - See Also:
-
getFieldsByType
Description copied from interface:EntityModelReturns all fields of the data type specified.- Specified by:
getFieldsByTypein interfaceEntityModel- Returns:
- May be empty.
-
getFieldsByBaseType
Description copied from interface:EntityModelReturns all fields that have the specified data type as base type.- Specified by:
getFieldsByBaseTypein interfaceEntityModel- Returns:
- May be empty.
-
getFirstFieldOfType
Description copied from interface:EntityModelversion, createts, updateuser ...- Specified by:
getFirstFieldOfTypein interfaceEntityModel- Returns:
- The first field as returned by getFieldsByType(), or null.
-
getFirstFieldOfBaseType
- Specified by:
getFirstFieldOfBaseTypein 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:
addFieldin interfaceEntityModel- Parameters:
f- The field- Throws:
IllegalArgumentException
-
addRelation
- Specified by:
addRelationin interfaceEntityModel- Parameters:
relation- The relation.- See Also:
-
getRelations
Description copied from interface:EntityModelGet all relations FROM this entity TO other entities; only one way. There seems to be no method for the opposite yet.- Specified by:
getRelationsin interfaceEntityModel
-
getRelationByName
Description copied from interface:EntityModelGet a relation by its name.- Specified by:
getRelationByNamein interfaceEntityModel- Parameters:
name- The name.- Returns:
- The relation or null if this relation doesn't exists!
-
hasRelation
- Specified by:
hasRelationin interfaceEntityModel- Parameters:
relName- The relation name to look for, eg "relFoo".- Returns:
- Tells if this model has a relation by that name.
- See Also:
-