Package mc.core.domain.generic.dobj
Class CollectionDO
java.lang.Object
mc.core.system.base.BaseBean
- All Implemented Interfaces:
IBaseDO<Collection>
-
Nested Class Summary
Nested classes/interfaces inherited from class mc.core.domain.base.dobj.AbstractBaseDO
AbstractBaseDO.Initializer -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmc.core.system.search.SearchFilterbuildSearchFilterForItems(Collection collection, boolean withLinked, Locale locale) voidcollectionManagedMove(List<? extends ICollectionManaged> collectionManagedObjects, Collection targetCollection) collectionsCreateFromUriPath(String uriPath, Collection parent, String uriSeparator) Create a collection path from a String of the format "col1/col2/col3" if collections not already exist.copy(Collection source, Collection targetParentCollection) Creates a deep copy of given HrcEntity, i.e.copy(Collection source, Collection parentForCopy, boolean addCopyNamePostfix) creates a flat copy of the given collection (does not copy child collections).copyCollection(Collection source, Collection targetParentCollection) method used by CollectionCopyActionlet.voiddelete(Collection collection, boolean force) NOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!voiddeleteSync(Collection collection) booleanexists(Collection collection) checks whether a collection with same URI already exists in parent folder.getDisplayPathMap(Collection collection, boolean withCurrent) Return ordered display path for collection and parentsgetRootCollection(ICollectionManaged entity) getRootCollection(ICollectionManaged entity, ComplexTypeEntity type) Retrieves or creates root collection.insert(Collection collection) booleanisCopyMoveAllowed(Collection collection, Collection targetCollection) return true, if moving/copy given collection to given target is possible,
i.e.voidmove(Collection collection, Collection targetCollection) save(Collection collection, DataMap dataMap) map data to entity if any, validate and savesetDisplayPath(List<Collection> collections, String separator) sets display path on each collection using given separator, default is using standard separator '/'.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.sort(List<Collection> collections, String separator) Sets display path for given collections and sorts them by display path.mc.core.domain.generic.dobj.CollectionDO.CollectionValidatorvalidator(Collection entity, DataMap map) 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.Methods inherited from class mc.core.domain.base.dobj.AbstractHrcEntityDO
getAllOffspringMethods 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
-
COLLECTION_PATH_SEPARATOR
- See Also:
-
-
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- mandatoryparentForCopy- 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:AbstractHrcEntityDOCreates 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:
copyin classAbstractHrcEntityDO<Collection>- Parameters:
source- HrcEntity, mandatorytargetParentCollection- 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
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<Collection>- Parameters:
collection- mandatoryforce- if true delete without usage check, which can result in db constraints error unless references are taken care of- Throws:
UserExceptionApplicationException
-
deleteSync
- 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 happenstargetCollection-- Throws:
ApplicationException
-
move
- 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- mandatorytargetCollection- optional- Returns:
- true if moving is possible, always false for the root collection
- Throws:
ApplicationException
-
insert
- Overrides:
insertin classAbstractComplexEntityDO<Collection>- Throws:
UserExceptionApplicationException
-
save
Description copied from interface:IBaseDOmap data to entity if any, validate and save- Specified by:
savein interfaceIBaseDO<Collection>- Overrides:
savein classAbstractEntityBaseDO<Collection>- Parameters:
collection- mandatorydataMap- optional- Returns:
- mapped entity
- Throws:
ApplicationException
-
getRootCollection
- 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
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 returnedparent- optional. if null, asset root collection will be useduriSeparator- optional. separator that is used between parts of uri, default is '/'- Returns:
- the last collection in hierarchy described by uriPath
- Throws:
ApplicationException
-
setDisplayPath
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
sets display path on each collection using given separator, default is using standard separator '/'.- Parameters:
collections- mandatoryseparator- optional- Returns:
- List of the display paths
- See Also:
-
sort
Sets display path for given collections and sorts them by display path.- Parameters:
collections- mandatoryseparator- optional- Returns:
- reference to the given list, sorted
- See Also:
-
getDisplayPathMap
Return ordered display path for collection and parents- Parameters:
collection- mandatorywithCurrent- 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: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<Collection>- Parameters:
entity- mandatorymap- optional- Returns:
- the validator
- Throws:
ApplicationException- the application exception
-