Class AspectAttributeRead<T extends ComplexEntity>

java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.dobj.AbstractAspect<T>
mc.core.domain.base.aspect.AspectAttributeRead<T>
Direct Known Subclasses:
AspectAttributeWrite

public abstract class AspectAttributeRead<T extends ComplexEntity> extends AbstractAspect<T>
abstract base aspect for attribute values. has the READ and the legacy WRITE methods
  • Constructor Details

    • AspectAttributeRead

      public AspectAttributeRead()
  • Method Details

    • parameter

      public ValueParamBean parameter()
      access to the attribute value parameter API
    • getTypeAttributesBySubType

      public List<TypeEntityToAttribute> getTypeAttributesBySubType(ComplexTypeEntity objectType, AttributeType.SubType subType)
      get all configured type attributes for an ComplexTypeEntity.
      Parameters:
      objectType - ComplexTypeEntity - mandatory
      subType - subType of attribute type - must be an subType.isConfigType. throws error if not.
      Returns:
      list of TypeEntityToAttribute assignments on this complex type
    • isAllowed

      public boolean isAllowed(ComplexEntity entity, Attribute attributeToCheck)
      check if type or object attribute is allowed by configuration for this object
      Parameters:
      entity - mandatory
      attributeToCheck - mandatory
      Returns:
      true if attribute is allowed by configuration or attributeType has isSystem flag
    • getAttributeValuesByType

      public AttributeValues getAttributeValuesByType(ComplexEntity object, AttributeType attributeType, DataValueFilter dvFilter)
    • getAttributeValuesByTypes

      public AttributeValues getAttributeValuesByTypes(List<? extends ComplexEntity> objects, List<AttributeType> attributeTypes, DataValueFilter dvFilter)
      searches for all entityAttributes of given complexEntities where attributes belong to given attributeTypes. For config-attributeTypes only loads configured attributes for each object. By default does not return children of group-attributes, set includeGroupChildren to true in DataValueFilter, if wished otherwise.
      Parameters:
      objects - optional, if empty returns empty AttributeValues.
      attributeTypes - mandatory, if empty returns empty AttributeValues.
      dvFilter - optional, can be null. filter AttributeValues by locale, territories and/or validDate, include/exclude group children.
      Returns:
      List of AttributeValue sorted first by ordering of objects, then by prio of attribute (for type attributes prio of typeEntityAttribute) and prioValue
    • getAttributeValuesByTypes

      public AttributeValues getAttributeValuesByTypes(ComplexEntity object, List<AttributeType> attributeTypes, DataValueFilter dvFilter)
      Parameters:
      object - mandatory
      attributeTypes - mandatory
      dvFilter - optional
      Returns:
      empty list, if complexEntity is not persistent or List of attributeTypes is empty
    • getAttributeValuesBySubType

      public AttributeValues getAttributeValuesBySubType(ComplexEntity object, AttributeType.SubType subType, DataValueFilter dvFilter)
      get all attributes of object for given AttributeType.SubType. Of config-attribute only return those which are currently allowed through configured TypeEntityToAttribute assignments. Of object attributes only return those that are within allowed attributeTypes of the entitie's type. type attributes are ordered by prio as configured by assignment to type, object attributes are ordered by entityToAttribute prio
      Parameters:
      object - mandatory
      subType - mandatory
      dvFilter - filter for data value query - optional, can be null
      Returns:
      list of AttributeValues for this object and subType
    • getAttributeValuesBySubType

      public AttributeValues getAttributeValuesBySubType(List<? extends ComplexEntity> objects, AttributeType.SubType subType, DataValueFilter dvFilter)
      Get all attributes of objects for given AttributeType.SubType. Of config-attribute only return those which are currently allowed through configured TypeEntityToAttribute assignments. Of object attributes only return those that are within allowed attributeTypes of the entity's type. The whole list is ordered by ordering of given objects. Within the AttributeValues for one object first come the type attributes, ordered by prio as configured by assignment to type, then object attributes ordered by entityToAttribute prio.
      Parameters:
      objects - mandatory, if empty returns empty list
      subType - mandatory
      dvFilter - filter for data value query - optional, can be null
      Returns:
      list of AttributeValues for this object and subType
    • getAttributeValueByAttribute

      public AttributeValue getAttributeValueByAttribute(ComplexEntity object, Attribute attribute, DataValueFilter dvFilter)
      get AttributeValue for one attribute
      Parameters:
      object - mandatory
      attribute - mandatory
      dvFilter - optional
      Returns:
      value if exists, else null
    • getAttributeValuesByAttributes

      public AttributeValues getAttributeValuesByAttributes(ComplexEntity object, List<Attribute> attributes, DataValueFilter dvFilter)
      Parameters:
      object - mandatory. if object is not persistent returns empty list
      attributes - optional, default is to return all configured type attribute values and all object attributes assigned to objects. When attributes are provided it is assumed that they are configured, use DataValueFilter.includeOnlyAllowed() to force check with config.
      dvFilter - optional, if null the default filter is used
      Returns:
      list of AttributeValues for this object and attributes, type attributes ordered by prio of attribute assignment to type, object attributes ordered by prio of entityToAttribute.
    • getAttributeValuesByAttributes

      public AttributeValues getAttributeValuesByAttributes(List<? extends ComplexEntity> objects, List<Attribute> attributes, DataValueFilter dvFilter)
      get all attribute values of objects for the given list of attributes, ordered first by ordering of objects, then by prio of attributes and prio of values. By default does not return children of group-attributes, set includeGroupChildren to true in DataValueFilter, if wished otherwise.
      WARNING: does not chekc
      Parameters:
      objects - mandatory, can be empty
      attributes - optional, default is to return all configured type attribute values and all object attributes assigned to objects. When attributes are provided it is assumed that they are configured, unless DataValueFilter.includeOnlyAllowed() is set to true.
      dvFilter - optional, if null the default filter is used
      Returns:
      list of AttributeValues for the objects and attributes
    • getAttributeValuesByAssignment

      public AttributeValues getAttributeValuesByAssignment(List<? extends ComplexEntity> objects, List<? extends IAttributeAssignment> assignments, DataValueFilter dvFilter)
      get all attribute values of objects for the given list of attributes, ordered first by ordering of objects, then by prio of attributes and prio of values. By default does not return children of group-attributes, set includeGroupChildren to true in DataValueFilter, if wished otherwise.
      WARNING: does not chekc
      Parameters:
      objects - mandatory, can be empty. Must be of same type
      assignments - list of IAttributeAssignment for type of objects. Mandatory, can be empty -> return empty list. NOTE: if the classes implementing IAttributeAssignment are not entities the attributes referenced must be managed!
      dvFilter - optional, if null the default filter is used
      Returns:
      list of AttributeValues for the objects and attributes defined by the assignments
    • getAttributeValuesByCollection

      public AttributeValues getAttributeValuesByCollection(ComplexEntity object, Collection collection, DataValueFilter dvFilter)
      Returns all AttributeValues of this entity that belong to given collection. For type attributes only returns configured, sorted by assignment prio, object attribute are returned sorted by prio ascending.
      Parameters:
      object - mandatory
      collection - mandatory
      dvFilter - optional
      Returns:
      AttributeValues
    • newAttributeValue

      public AttributeValue newAttributeValue(ComplexEntity object, Attribute attribute)
    • newAttributeValue

      public AttributeValue newAttributeValue(ComplexEntity object, IAttributeAssignment assignment)
    • getPreviewAsset

      public Asset getPreviewAsset(T entity)
      Parameters:
      entity - Entity for which to get preview.
      Returns:
      Preview image. Fallback to parent applies if entity does not define a preview itself. Might return null if no preview could be found.
    • getPreviewAssetsMap

      public Map<ComplexEntity,Asset> getPreviewAssetsMap(List<T> entityList) throws ApplicationException
      Returns the assets used as default preview asset which is found by the following search: Get all type attributes from ComplexEntity's type that have an Asset-Datatype, ordered by prio. Take the first and try to get Asset in content locale or its master locale from DataValue.
      Parameters:
      entityList - mandatory, if empty return empty map.
      Returns:
      Mapping of entities to their previews. Entities that do not have previews are not included in the mapping.
      Throws:
      ApplicationException