Class DataValueTO

java.lang.Object
mc.core.domain.generic.DataValueTO
All Implemented Interfaces:
Serializable

public class DataValueTO extends Object implements Serializable
container to transfer attribute value data for save from GUI clients or import channel. Use appropriate set-Methods to set data in DataValueTO. Use method AspectAttributeWrite.valueSet(mc.core.model.base.ComplexEntity, DataValueTO) or AspectAttributeWrite.valuesSet(mc.core.model.base.ComplexEntity, List) to pass DataValueTO(s) to backend for save.
See Also:
  • Constructor Details

    • DataValueTO

      public DataValueTO(Attribute attribute, DataMap map)
      Constructor to create a DataValueTO from data in given map (e.g. created from RI-request). Map must contain key-value-pairs using as keys the enum DataValueTO.Key. Entities as values are stored by their id. For creating a DataValueTO programmatically constructor DataValueTO(Attribute) should be preferred, using set-Methods to set data.
      Parameters:
      attribute - for which a value should be set. mandatory
      map - containing the data for the DataValueTO, mandatory.
    • DataValueTO

      public DataValueTO(Attribute attribute)
      Constructor to create a DataValueTO.
      Parameters:
      attribute - for which a value should be set. mandatory
  • Method Details

    • getAttribute

      public Attribute getAttribute()
    • changed

      public DataValueTO changed()
      Optimization: Call to mark this DataValueTO as changed. This flag should be evaluated prior to calling a save-Method in AttributeAspect, to filter DataValueTOs where data has not changed. If no possibility exists to compare new data to old data do not call. Flag is ignored in save procedure.
      Returns:
      this for fluent API
    • isChanged

      public boolean isChanged()
      Returns:
      value of DataValueTO's flag changed.
    • toDataMap

      public DataMap toDataMap()
      Get copy of the internal data map
    • setEntityToAttribute

      public DataValueTO setEntityToAttribute(long id)
      Set the entityToAttribute-id to signal that one specific value of a multivalue attribute should be edited. The e2a-id must be the id of an existing e2a for this attribute and entity.
      Parameters:
      id -
      Returns:
      this for fluent API
    • setEntityToAttribute

      public DataValueTO setEntityToAttribute(EntityToAttribute e2a)
      Set the entityToAttribute to signal that one specific value of a multivalue attribute should be edited. The e2a must be an existing e2a for this attribute and entity. Equivalent to calling setEntityToAttribute(long) with e2a.getId().
      Parameters:
      e2a - mandatory
      Returns:
      this for fluent API
    • getEntityToAttributeId

      public long getEntityToAttributeId()
      Return value of entityToAttribute-id if set, default 0.
      Returns:
      long
    • setValidFrom

      public DataValueTO setValidFrom(Calendar calValidFrom)
      Set valid-from-date for this attribute value (e2a).
      Parameters:
      calValidFrom - optional, ignored if null
      Returns:
      this for fluent API
    • setValidUntil

      public DataValueTO setValidUntil(Calendar calValidUntil)
      Set valid-until-date for this attribute value (e2a).
      Parameters:
      calValidUntil - optional, ignored if null
      Returns:
      this for fluent API
    • setTerritory

      public DataValueTO setTerritory(long territoryId)
      Set territoryId for this attribute value (e2a), attribute must be territory dependent.
      Parameters:
      territoryId - must be valid id of an existing territory for territory dependent attributes
      Returns:
      this for fluent API
    • setTerritory

      public DataValueTO setTerritory(Territory territory)
      Set territory for this attribute value (e2a), attribute must be territory dependent. Equivalent to calling method setTerritory(long) with territory.getId().
      Parameters:
      territory - mandatory
      Returns:
      this for fluent API
    • setPrio

      public DataValueTO setPrio(int iPrio)
      Set the prio of entityToAttribute that determines sort order of this attribute value within list of values of different attributes for this entity. No check with prio of other entityToAttributes is done upon save. Also for multivalue attributes all e2as for same attribute should have same prio, this must be taken care of by the caller. Use AspectAttributeWrite.changeOrder(mc.core.model.base.ComplexEntity, Attribute, boolean, boolean) to create consistent values for prios of e2as that takes into account multivalues as well.
      Parameters:
      iPrio - int
      Returns:
      this for fluent API
    • setPrioValue

      public DataValueTO setPrioValue(int iPrioValue)
      Set prio for e2a that determines ordering within values of the same attribute. No check with prioValue of other entityToAttributes for same attribute is done upon save, use method AspectAttributeWrite.valueChangeOrder(EntityToAttribute, boolean) for consistent ordering of values.
      Parameters:
      iPrioValue - int
      Returns:
      this for fluent API
    • setParameter

      public DataValueTO setParameter(DataMap paramMap)
      set additional parameter for e2a. existing values are deleted if key is in map and value is null. NOTE: this is a convenience method for setting additional parameter values together with the data for respective dataValue in one step. parameter are only stored if any data for value is set in TO (textValue, numericValue ...). for setting parameter independently from data value use AspectAttributeRead.parameter() API.
      Parameters:
      paramMap - map with key/value pairs. if value is not serializable it will be converted to String. if value is null respective parameter is deleted if exists
      Returns:
      this for fluent API
    • getDataValueId

      public long getDataValueId()
      Returns:
      the id of the corresponding datavalue if set. Only needed for remove, use removeDataValue(long) to set.
    • getInternalDescription

      public String getInternalDescription()
      Returns:
      parameter internalDescription from map
    • setDataValueSet

      public DataValueTO setDataValueSet(long dvSetId)
      Set the id of the DataValueSet if > 0, needed for setting enumerated values and editing standard/sample/default values of attribute.
      Parameters:
      dvSetId - should be a valid id of a standard value of this attribute, ignored if <= 0
      Returns:
      this for fluent API
    • setDataValueSet

      public DataValueTO setDataValueSet(DataValueSet dvSet)
      Set the id of the DataValueSet if > 0, needed for setting enumerated values and editing standard/sample/default values of attribute. Same as calling setDataValueSet(long) with dvSet.getId().
      Parameters:
      dvSet - should be a valid id of a standard value of this attribute, ignored if <= 0
      Returns:
      this for fluent API
    • setDataValueSet

      public DataValueTO setDataValueSet(Object dataValueSetKey)
      Set key (internalDescription, id or display) of DataValueSet for setting an enumerated value.
      Parameters:
      dataValueSetKey -
      Returns:
      this for fluent API
    • setEnumValue

      public DataValueTO setEnumValue(Object dataValueSetKey)
      Same as setDataValueSet(Object). for backwards compatibility
      Parameters:
      dataValueSetKey -
      Returns:
      this for fluent API
    • getDataValueSetId

      public long getDataValueSetId()
      Returns:
      value for key "dataValueSet" from map as id
    • getDataValueSetKey

      public Object getDataValueSetKey()
      Returns:
      value for key "dataValueSet" from map if not empty, otherwise the value for key "internalDescription"
    • setValueType

      public DataValueTO setValueType(DataValueSet.ValueType valType)
      Usually not needed to be set (is determined from DataValueHandler), only for differentiating between SAMPLE and DEFAULT values for attribute
    • setInternalDescription

      public DataValueTO setInternalDescription(String intDescr)
      Set the internalDescription of a dataValueSet when editing standard values of an attribute. Not for selecting a standard value as value for an entity, use setEnumValue(String)) for this.
      Parameters:
      intDescr -
      Returns:
      this for fluent API
    • setPrioSet

      public DataValueTO setPrioSet(int iPrio)
      Set prio of a dataValueSet for sort standard value only
    • setReadonly

      public DataValueTO setReadonly(boolean readOnly)
      Set a dataValueSet to read only. Not used to date, only relevant for proposal values.
      Parameters:
      readOnly -
      Returns:
      this for fluent API
    • setAssetValue

      public DataValueTO setAssetValue(long assetId, long localeId)
      DVAsset: set asset value for given locale.
      Parameters:
      assetId - should be valid id of existing asset
      localeId - optional, ignored if 0
      Returns:
    • setAssetValue

      public DataValueTO setAssetValue(Asset asset)
      DVAsset: set asset value for locale independent DVAsset, otherwise for content locale.
      Parameters:
      asset - mandatory
      Returns:
      this for fluent API
    • setAssetText

      public DataValueTO setAssetText(String assetText)
      DVAsset: Set an additional text for asset like image caption, legend etc. NOT USED.
    • setBooleanValue

      public DataValueTO setBooleanValue(Boolean value)
      DVBoolean: set Boolean value
      Parameters:
      value - optional, use setBooleanValue(null) to specify noChoice with DTBoolean.isAllowNoChoice()
      Returns:
      this for fluent API
    • setTextValue

      public DataValueTO setTextValue(String text)
      DVText: Set text value for locale independent value, otherwise for content locale
      Parameters:
      text - ignored if null or empty. Whitespace will be removed from start and end of given text.
      Returns:
      this for fluent API
    • setTextValue

      public DataValueTO setTextValue(String text, Locale locale)
      DVText: Set text value for locale dependent value in given locale. For locale independent value locale is ignored.
      Parameters:
      text - ignored if null or empty. Whitespace will be removed from start and end of given text.
      locale - mandatory
      Returns:
      this for fluent API
    • setTextValue

      public DataValueTO setTextValue(String text, long localeId)
      Parameters:
      text - ignored if null or empty. Whitespace will be removed from start and end of given text.
      localeId - ignored if 0
      Returns:
      this for fluent API
      See Also:
    • setTextValueTO

      public DataValueTO setTextValueTO(TextValueTO textValueTO)
      DVText: only relevant for text pool
      Parameters:
      textValueTO - ignored if null
      Returns:
      this for fluent API
    • getTextValueTO

      public TextValueTO getTextValueTO()
    • setLocale

      public DataValueTO setLocale(Locale locale)
      For locale dependent DataValues( DVText, DVAsset), set locale if other than content locale
      Parameters:
      locale - mandatory
      Returns:
      this for fluent API
    • setLocale

      public DataValueTO setLocale(long localeId)
      For locale dependent DataValues( DVText, DVAsset), set locale if other than content locale
      Parameters:
      localeId - ignored it 0
      Returns:
      this for fluent API
    • setDateValue

      public DataValueTO setDateValue(Calendar cal)
      DVDate: set value
      Parameters:
      cal -
      Returns:
      this for fluent API
    • setNumericValue

      public DataValueTO setNumericValue(Double numValue)
      DVNumeric: set value
      Parameters:
      numValue -
      Returns:
      this for fluent API
    • setNumericValue

      public DataValueTO setNumericValue(Double numValue, long unitId)
      DVNumeric: set value with unit
      Parameters:
      numValue -
      unitId - , ignored if 0
      Returns:
      this for fluent API
    • setNumericValue

      public DataValueTO setNumericValue(Double numValue, Unit unit)
      DVNumeric: set value with unit
      Parameters:
      numValue -
      unit - optional
      Returns:
      this for fluent API
    • setPriceValue

      public DataValueTO setPriceValue(Double price)
      DVPrice set price value
      Parameters:
      price -
      Returns:
      this for fluent API
    • setPricelist

      public DataValueTO setPricelist(Pricelist pricelist)
      DVPrice set pricelist for pricelist dependent value
      Parameters:
      pricelist - mandatory
      Returns:
      this for fluent API
    • setPricelist

      public DataValueTO setPricelist(long pricelistId)
      DVPrice set pricelist for pricelist dependent value
      Parameters:
      pricelistId - ignored if 0
      Returns:
      this for fluent API
    • setCurrency

      public DataValueTO setCurrency(Currency currency)
      DVPrice set currency for pricelist independent value
      Parameters:
      currency - mandatory
      Returns:
      this for fluent API
    • setCurrency

      public DataValueTO setCurrency(long currencyId)
      DVPrice set currency for pricelist independent value
      Parameters:
      currencyId - ignored if 0
      Returns:
      this for fluent API
    • setPatternValues

      public DataValueTO setPatternValues(List<Object> values)
      DVPattern: set all values (not the blanks) in the right order, list must contain a null element if a single value is not set. To date a value object can be a String or a Long (unitId) or null which must correspond to the place in the pattern. For blanks the value list does not need to contain a value.
      Parameters:
      values - mandatory
    • isToRemove

      public boolean isToRemove()
    • removeDataValue

      public DataValueTO removeDataValue(long dataValueId)
      Mark a DataValue to be deleted
      Parameters:
      dataValueId - mandatory, must be the valid id of an existing dataValue for this attribute and entity
      Returns:
      this for fluent API
    • removeText

      public DataValueTO removeText(long dataValueId, Locale locale)
      For locale dependent DataValues: DVAsset mark to be deleted if it has the locale. DVText: remove text in locale
      Parameters:
      dataValueId - mandatory, must be the valid id of an existing dataValue for this attribute and entity
      Returns:
      this for fluent API
    • removeE2A

      public DataValueTO removeE2A(long entityToAttributeId)
      Mark an EntityToAttribute to be deleted with all its DataValues
      Parameters:
      entityToAttributeId - mandatory, must be the valid id of an existing e2a for this attribute and entity
      Returns:
      this for fluent API
    • toString

      public String toString()
      Overrides:
      toString in class Object