Package mc.core.domain.generic.dobj
Class AttributeDO
java.lang.Object
mc.core.system.base.BaseBean
-
Nested Class Summary
Nested classes/interfaces inherited from class mc.core.domain.base.dobj.AbstractBaseDO
AbstractBaseDO.Initializer -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringkey for attribute calculation data, stored as entity data -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy(Attribute source, Collection parentCollection) creates a copy of given attribute with all settings, standard values, sample and default value if exist.voiddefaultValueSet(DataValueTO dvTO) voidNOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!getCalculationData(Attribute attribute) gets the calculation script corresponding to the given attributebooleanhasCalculationData(Attribute attribute) checks if the given attribute has a calculation scriptvoidpresetValueRemove(Attribute attribute, DataValueSet.ValueType valueType) voidpresetValueRemoveValue(Attribute attribute, DataValue dataValue) voidsampleValueSet(DataValueTO dvTO) map data to entity if any, validate and savevoidsetCalculationData(Attribute attribute, String data) sets the calculation script for the given attributevoidstandardValueDelete(Attribute attribute, DataValueSet dataValueSet, boolean force) deletes the complete DataValueSet with all values and removes it from standardValues of attributevoidstandardValueEdit(DataValueTO dvTO) edits or inserts the value represented by the DataValueTO as standard or proposal value of attribute.standardValueGetFromKey(Attribute attribute, Object key, Locale locale) tries to find a standardValue of given attribute by its key which could be the id of the DataValueSet or its internalDescription or the displayString of the dataValue in locale if given otherwise contentLocalevoidstandardValuesEdit(Attribute attribute, List<DataValueTO> dvTOList) edits or inserts values, each represented by a DataValueTO, as standard or proposal value of attribute.voidstandardValuesRemoveValue(Attribute attribute, DataValue dataValue, boolean force) deletes given value from standardValue, also deletes the complete DataValueSet, if value was the lastmc.core.domain.generic.dobj.AttributeDO.AttributeValidatorfor persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1.Methods inherited from class mc.core.domain.base.dobj.AbstractComplexEntityDO
addDefaultSearchCriteria, assertPermission, assertPermission, attributes, copy, copyDataSync, copyToCollection, doRecursiveActionAsync, edit, entityProfileApply, entityProfileApply, filter, getCollectionHierarchies, getCollectionsAll, getFromExternalKey, getFromKeySearchFilter, getUserRole, lifecycle, newComplexEntityEvent, onChange, parameter, permissions, prepareSearchFilter, relations, secondaryCollectionAdd, secondaryCollectionCopy, secondaryCollectionMove, secondaryCollectionRemove, setRightInheritanceDisabled, states, translate, versions, watchesMethods inherited from class mc.core.domain.base.dobj.AbstractEntityBaseDO
getFromInternalDescription, sendEvent, sendEventMethods inherited from class mc.core.domain.base.dobj.AbstractBaseDO
delete, getAll, getAllActive, getEntityDisplay, getFromId, getFromKey, getOne, map, map, save
-
Field Details
-
ED_CALCULATION_DATA
key for attribute calculation data, stored as entity data- See Also:
-
-
Constructor Details
-
AttributeDO
public AttributeDO()
-
-
Method Details
-
save
public Attribute save(Attribute attribute, DataMap dataMap) throws ApplicationException, UserException Description copied from interface:IBaseDOmap data to entity if any, validate and save- Specified by:
savein interfaceIBaseDO<Attribute>- Overrides:
savein classAbstractEntityBaseDO<Attribute>- Parameters:
attribute- mandatorydataMap- optional- Returns:
- mapped entity
- Throws:
ApplicationExceptionUserException
-
insert
- Overrides:
insertin classAbstractComplexEntityDO<Attribute>- Throws:
ApplicationException
-
delete
Description copied from class:AbstractBaseDONOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!- Overrides:
deletein classAbstractComplexEntityDO<Attribute>- Parameters:
attribute- mandatoryforce- if true delete without usage check, which can result in db constraints error unless references are taken care of- Throws:
ApplicationException
-
copy
creates a copy of given attribute with all settings, standard values, sample and default value if exist. If source attribute is parent of a group also creates copies of the group children.- Parameters:
source- mandatoryparentCollection- optional, if null, uses collection of source attribute- Returns:
- copied attribute
- Throws:
ApplicationException
-
presetValueRemove
public void presetValueRemove(Attribute attribute, DataValueSet.ValueType valueType) throws ApplicationException - Throws:
ApplicationException
-
defaultValueSet
- Throws:
ApplicationException
-
sampleValueSet
- Throws:
ApplicationException
-
presetValueRemoveValue
public void presetValueRemoveValue(Attribute attribute, DataValue dataValue) throws ApplicationException - Throws:
ApplicationException
-
standardValueDelete
public void standardValueDelete(Attribute attribute, DataValueSet dataValueSet, boolean force) throws ApplicationException deletes the complete DataValueSet with all values and removes it from standardValues of attribute- Parameters:
attribute- mandatorydataValueSet- mandatoryforce- if true no check if this standardValue is used (may result in an exception from database), default is false- Throws:
ApplicationException
-
standardValuesRemoveValue
public void standardValuesRemoveValue(Attribute attribute, DataValue dataValue, boolean force) throws ApplicationException deletes given value from standardValue, also deletes the complete DataValueSet, if value was the last- Parameters:
attribute- mandatorydataValue- mandatoryforce- if true no check if this standardValue is used (may result in an exception from database), default is false- Throws:
ApplicationException
-
standardValuesEdit
public void standardValuesEdit(Attribute attribute, List<DataValueTO> dvTOList) throws ApplicationException edits or inserts values, each represented by a DataValueTO, as standard or proposal value of attribute. if value is already persistent the dataValueSet (id or key) must be present in DataValueTO and the dataValueSet must be part of the attribute standard values. If new the DataValueTO must contain the valueType (ValueType.SHARED or ValueType.PROPOSAL). The DataValueSet will be inserted. ordering will not be changed - new values are inserted with prio 0. locale is set: either undefinedLocale if localeIndependent, given locale or if null the current ContentLocale.
NOTE: only DataValueTOs for values that actually have changed should be provided to avoid performance overhead from rebuilding the fti index unnecessarily.- Parameters:
attribute- mandatorydvTOList- mandatory, can be empty (nothing happens)- Throws:
ApplicationException
-
standardValueEdit
edits or inserts the value represented by the DataValueTO as standard or proposal value of attribute. The DataValueTO must contain the attributes. If value is already persistent the dataValueSet (id or key) must be present in DataValueTO and the dataValueSet must be part of the attribute standard values. If new the DataValueTO must contain the valueType (ValueType.SHARED or ValueType.PROPOSAL). The DataValueSet will be inserted. ordering will not be changed - new values are inserted with prio 0. locale is set: either undefinedLocale if localeIndependent, given locale or if null the current ContentLocale- Throws:
ApplicationException
-
standardValueGetFromKey
public DataValueSet standardValueGetFromKey(Attribute attribute, Object key, Locale locale) throws EntityNotFoundException tries to find a standardValue of given attribute by its key which could be the id of the DataValueSet or its internalDescription or the displayString of the dataValue in locale if given otherwise contentLocale- Parameters:
attribute- mandatory, must have standard/proposal valueskey- mandatory, must be a valid key of a standardValue of this attributelocale- optional, default is content locale- Returns:
- the DataValueSet
- Throws:
EntityNotFoundException- if no standardValues of this attribute exists with this key
-
dataValueGetFromKey
- Parameters:
key- mandatory, id of dataValue- Throws:
EntityNotFoundException
-
setCalculationData
sets the calculation script for the given attribute- Parameters:
attribute- the attribute to calculatedata- script to calculate this attribute- Throws:
ApplicationException- if script data could not be set to the attribute
-
getCalculationData
gets the calculation script corresponding to the given attribute- Parameters:
attribute- the attribute to get the calculation data from- Returns:
- String containing the script to calculate the attribute if exists, null otherwise
-
hasCalculationData
checks if the given attribute has a calculation script- Parameters:
attribute- attribute to check- Returns:
- true if a script has been set to this attribute, false otherwise
-
validator
public mc.core.domain.generic.dobj.AttributeDO.AttributeValidator validator(Attribute attribute, DataMap map) throws ApplicationException Description copied from class:AbstractBaseDOfor persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1. validator( navigationHrc, dataMap).thatValidField( NavigationHrc.Field.navigationHrcType).validate(); 2. validator( navigation, dataMap).thatValidField( Navigation.Field.navigationType, Navigation.Field.navigationHrc) .thatNotNullIf( HrcEntity.Field.parent, n -> n.getNavigationType().getParentNavigationType() != null).validate(); 3. validator( entity, dataMap).thatValidField( Country.Field.iso2Code, "message.validate.Country.iso2Code.missing").thatUnique( Country.Field.iso2Code).validate();- Overrides:
validatorin classAbstractBaseDO<Attribute>- Parameters:
attribute- mandatorymap- optional- Returns:
- the validator
- Throws:
ApplicationException- the application exception
-