Class CollectionDO

All Implemented Interfaces:
IBaseDO<Collection>

public class CollectionDO extends AbstractHrcEntityDO<Collection>
  • Field Details

  • Constructor Details

    • CollectionDO

      public CollectionDO()
  • Method Details

    • copy

      public Collection copy(Collection source, Collection parentForCopy, boolean addCopyNamePostfix) throws ApplicationException
      creates a flat copy of the given collection (does not copy child collections).
      Parameters:
      source - mandatory
      parentForCopy - mandatory. copies of collections should always have a parent collection. NOTE: only the system is allowed to create top level root collections (@see getRootCollection)
      addCopyNamePostfix - whether the URI of new collection should have to copy name postfix.
      Returns:
      copy
      Throws:
      ApplicationException
    • copy

      public Collection copy(Collection source, Collection targetParentCollection) throws ApplicationException
      Description copied from class: AbstractHrcEntityDO
      Creates a deep copy of given HrcEntity, i.e. copies also all offspring. For large hierarchical trees this can take substantial time. Subclass of HrcEntity passed to this method must implement a constructor that takes as sole argument an instance of this class, otherwise an ApplicationException is thrown. The copy constructor should set all properties that must be copied but not the dependent objects such as entityToAttributes.
      Overrides:
      copy in class AbstractHrcEntityDO<Collection>
      Parameters:
      source - HrcEntity, mandatory
      targetParentCollection - HrcEntity, mandatory if hierarchy level of source demands a parent. Gives the parent to which copied object should belong. parentForCopy must be of same type as parent of source if the levels of the hierarchy are differentiated by type.
      Returns:
      copy
      Throws:
      ApplicationException
    • copyCollection

      public Collection copyCollection(Collection source, Collection targetParentCollection) throws ApplicationException
      method used by CollectionCopyActionlet. Only copies the collection itself with its data, no recursion to copy sub collection or collection items.
      Throws:
      ApplicationException
    • delete

      public void delete(Collection collection, boolean force) throws UserException, 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<Collection>
      Parameters:
      collection - mandatory
      force - if true delete without usage check, which can result in db constraints error unless references are taken care of
      Throws:
      UserException
      ApplicationException
    • deleteSync

      public void deleteSync(Collection collection) throws ApplicationException
      Throws:
      ApplicationException
    • buildSearchFilterForItems

      public mc.core.system.search.SearchFilter buildSearchFilterForItems(Collection collection, boolean withLinked, Locale locale)
    • collectionManagedMove

      public void collectionManagedMove(List<? extends ICollectionManaged> collectionManagedObjects, Collection targetCollection) throws ApplicationException
      Parameters:
      collectionManagedObjects - mandatory, if empty nothing happens
      targetCollection -
      Throws:
      ApplicationException
    • move

      public void move(Collection collection, Collection targetCollection) throws ApplicationException
      Throws:
      ApplicationException
    • isCopyMoveAllowed

      public boolean isCopyMoveAllowed(Collection collection, Collection targetCollection) throws ApplicationException
      return true, if moving/copy given collection to given target is possible,
      i.e. targetCollection is not in children tree of this collection (endless for recursion)
      Parameters:
      collection - mandatory
      targetCollection - optional
      Returns:
      true if moving is possible, always false for the root collection
      Throws:
      ApplicationException
    • insert

      public Collection insert(Collection collection) throws UserException, ApplicationException
      Overrides:
      insert in class AbstractComplexEntityDO<Collection>
      Throws:
      UserException
      ApplicationException
    • save

      public Collection save(Collection collection, DataMap dataMap) throws ApplicationException
      Description copied from interface: IBaseDO
      map data to entity if any, validate and save
      Specified by:
      save in interface IBaseDO<Collection>
      Overrides:
      save in class AbstractEntityBaseDO<Collection>
      Parameters:
      collection - mandatory
      dataMap - optional
      Returns:
      mapped entity
      Throws:
      ApplicationException
    • getRootCollection

      public Collection getRootCollection(ICollectionManaged entity) throws ApplicationException
      Throws:
      ApplicationException
    • getRootCollection

      public Collection getRootCollection(ICollectionManaged entity, ComplexTypeEntity type) throws ApplicationException
      Retrieves or creates root collection.
      Parameters:
      entity - Dummy to derivate entity class for root collection.
      type - Entity type.
      Returns:
      Root collection.
      Throws:
      ApplicationException
    • exists

      public boolean exists(Collection collection) throws ApplicationException
      checks whether a collection with same URI already exists in parent folder. parent and URI must be set in given collection.
      Throws:
      ApplicationException
    • collectionsCreateFromUriPath

      public Collection collectionsCreateFromUriPath(String uriPath, Collection parent, String uriSeparator) throws ApplicationException
      Create a collection path from a String of the format "col1/col2/col3" if collections not already exist. Does not check permissions on parent (internal system method).
      Parameters:
      uriPath - optional. if null, parent (or root) will be returned
      parent - optional. if null, asset root collection will be used
      uriSeparator - optional. separator that is used between parts of uri, default is '/'
      Returns:
      the last collection in hierarchy described by uriPath
      Throws:
      ApplicationException
    • setDisplayPath

      public String setDisplayPath(Collection collection, String separator)
      Creates a string of root collection name followed by collection path starting with child of root if exist and going to this collection. if separator is null, uses default separator "/". set's display path in given collection (transient field).
    • setDisplayPath

      public List<String> setDisplayPath(List<Collection> collections, String separator)
      sets display path on each collection using given separator, default is using standard separator '/'.
      Parameters:
      collections - mandatory
      separator - optional
      Returns:
      List of the display paths
      See Also:
    • sort

      public List<Collection> sort(List<Collection> collections, String separator)
      Sets display path for given collections and sorts them by display path.
      Parameters:
      collections - mandatory
      separator - optional
      Returns:
      reference to the given list, sorted
      See Also:
    • getDisplayPathMap

      public Map<Collection,String> getDisplayPathMap(Collection collection, boolean withCurrent)
      Return ordered display path for collection and parents
      Parameters:
      collection - mandatory
      withCurrent - optional. include the given collection
      Returns:
      map with collection as key and its display as value in content locale
    • validator

      public mc.core.domain.generic.dobj.CollectionDO.CollectionValidator validator(Collection entity, 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<Collection>
      Parameters:
      entity - mandatory
      map - optional
      Returns:
      the validator
      Throws:
      ApplicationException - the application exception