Class DefaultOrgUnitHierarchyService
- java.lang.Object
-
- de.hybris.platform.commerceservices.organization.services.impl.DefaultOrgUnitHierarchyService
-
- All Implemented Interfaces:
OrgUnitHierarchyService
public class DefaultOrgUnitHierarchyService extends java.lang.Object implements OrgUnitHierarchyService
Default implementation of theOrgUnitHierarchyServiceinterface.
-
-
Field Summary
Fields Modifier and Type Field Description static charDELIMITERCharacter used as a delimiter between unit UIDs in the path.
-
Constructor Summary
Constructors Constructor Description DefaultOrgUnitHierarchyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeforeUpdate(OrgUnitModel unit, OrgUnitModel parentUnit)protected java.util.Set<OrgUnitModel>generatePathForUnit(OrgUnitModel unit, OrgUnitModel parentUnit)<T extends OrgUnitModel>
voidgenerateUnitPaths(java.lang.Class<T> unitType)Generates thepathvalue of allOrgUnitModelobjects of the given unit type.protected java.util.Set<OrgUnitModel>getChildrenOfSameType(OrgUnitModel unit)protected ModelServicegetModelService()protected OrgUnitDaogetOrgUnitDao()protected OrgUnitModelgetParentUnit(OrgUnitModel unit)protected SessionServicegetSessionService()protected voidhandleTransactionException(java.lang.Exception e)voidsaveChangesAndUpdateUnitPath(OrgUnitModel unit)Saves all changes to the givenOrgUnitModeland updates itspathvalue as well as thepathvalues for all its descendants of the same type subsequently.voidsetModelService(ModelService modelService)voidsetOrgUnitDao(OrgUnitDao orgUnitDao)voidsetSessionService(SessionService sessionService)protected voidupdateUnitPath(OrgUnitModel unit)protected voidvalidatePath(OrgUnitModel parentUnit)
-
-
-
Field Detail
-
DELIMITER
public static final char DELIMITER
Character used as a delimiter between unit UIDs in the path.- See Also:
- Constant Field Values
-
-
Method Detail
-
generateUnitPaths
public <T extends OrgUnitModel> void generateUnitPaths(java.lang.Class<T> unitType)
Generates thepathvalue of allOrgUnitModelobjects of the given unit type. The process starts with the root units, i.e. the ones that don't have a parent of the same type, and will traverse the hierarchy tree for each of them. All changes to affected items are persisted.
Note: The default implementations ofgenerateUnitPaths(Class)andsaveChangesAndUpdateUnitPath(OrgUnitModel)aresynchronizedin order to avoid inconsistent path values in case two threads try to access one of the methods at the same time.- Specified by:
generateUnitPathsin interfaceOrgUnitHierarchyService- Parameters:
unitType- Determines the type to generatepathvalues for. Sub-types will be ignored. May not be null.
-
saveChangesAndUpdateUnitPath
public void saveChangesAndUpdateUnitPath(OrgUnitModel unit)
Saves all changes to the givenOrgUnitModeland updates itspathvalue as well as thepathvalues for all its descendants of the same type subsequently. All changes to affected items are persisted.
This method should be called whenever changes to the unit include a change of its parent unit. Implementations have to make sure that all changes are rolled back in case the creation of path values fails.
Note: The default implementations ofgenerateUnitPaths(Class)andsaveChangesAndUpdateUnitPath(OrgUnitModel)aresynchronizedin order to avoid inconsistent path values in case two threads try to access one of the methods at the same time.- Specified by:
saveChangesAndUpdateUnitPathin interfaceOrgUnitHierarchyService- Parameters:
unit- TheOrgUnitModelto update. May not be null.
-
updateUnitPath
protected void updateUnitPath(OrgUnitModel unit)
-
generatePathForUnit
protected java.util.Set<OrgUnitModel> generatePathForUnit(OrgUnitModel unit, OrgUnitModel parentUnit)
-
beforeUpdate
protected void beforeUpdate(OrgUnitModel unit, OrgUnitModel parentUnit)
-
validatePath
protected void validatePath(OrgUnitModel parentUnit)
-
getParentUnit
protected OrgUnitModel getParentUnit(OrgUnitModel unit)
-
getChildrenOfSameType
protected java.util.Set<OrgUnitModel> getChildrenOfSameType(OrgUnitModel unit)
-
handleTransactionException
protected void handleTransactionException(java.lang.Exception e)
-
getOrgUnitDao
protected OrgUnitDao getOrgUnitDao()
-
setOrgUnitDao
public void setOrgUnitDao(OrgUnitDao orgUnitDao)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
-