Class AttributeDO

All Implemented Interfaces:
IBaseDO<Attribute>

public class AttributeDO extends AbstractComplexEntityDO<Attribute>
  • Field Details

    • ED_CALCULATION_DATA

      public static final String 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: IBaseDO
      map data to entity if any, validate and save
      Specified by:
      save in interface IBaseDO<Attribute>
      Overrides:
      save in class AbstractEntityBaseDO<Attribute>
      Parameters:
      attribute - mandatory
      dataMap - optional
      Returns:
      mapped entity
      Throws:
      ApplicationException
      UserException
    • insert

      public Attribute insert(Attribute attribute) throws ApplicationException
      Overrides:
      insert in class AbstractComplexEntityDO<Attribute>
      Throws:
      ApplicationException
    • delete

      public void delete(Attribute attribute, boolean force) throws ApplicationException
      Description copied from class: AbstractBaseDO
      NOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!
      Overrides:
      delete in class AbstractComplexEntityDO<Attribute>
      Parameters:
      attribute - mandatory
      force - if true delete without usage check, which can result in db constraints error unless references are taken care of
      Throws:
      ApplicationException
    • copy

      public Attribute copy(Attribute source, Collection parentCollection) throws ApplicationException
      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 - mandatory
      parentCollection - 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

      public void defaultValueSet(DataValueTO dvTO) throws ApplicationException
      Throws:
      ApplicationException
    • sampleValueSet

      public void sampleValueSet(DataValueTO dvTO) throws ApplicationException
      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 - mandatory
      dataValueSet - mandatory
      force - 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 - mandatory
      dataValue - mandatory
      force - 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 - mandatory
      dvTOList - mandatory, can be empty (nothing happens)
      Throws:
      ApplicationException
    • standardValueEdit

      public void standardValueEdit(DataValueTO dvTO) throws ApplicationException
      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 values
      key - mandatory, must be a valid key of a standardValue of this attribute
      locale - optional, default is content locale
      Returns:
      the DataValueSet
      Throws:
      EntityNotFoundException - if no standardValues of this attribute exists with this key
    • dataValueGetFromKey

      public DataValue dataValueGetFromKey(String key) throws EntityNotFoundException
      Parameters:
      key - mandatory, id of dataValue
      Throws:
      EntityNotFoundException
    • setCalculationData

      public void setCalculationData(Attribute attribute, String data) throws ApplicationException
      sets the calculation script for the given attribute
      Parameters:
      attribute - the attribute to calculate
      data - script to calculate this attribute
      Throws:
      ApplicationException - if script data could not be set to the attribute
    • getCalculationData

      public String getCalculationData(Attribute attribute)
      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

      public boolean hasCalculationData(Attribute attribute)
      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: AbstractBaseDO
      for 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:
      validator in class AbstractBaseDO<Attribute>
      Parameters:
      attribute - mandatory
      map - optional
      Returns:
      the validator
      Throws:
      ApplicationException - the application exception