Package org.apache.cayenne.ashwood
Class AshwoodEntitySorter
java.lang.Object
org.apache.cayenne.ashwood.AshwoodEntitySorter
- All Implemented Interfaces:
EntitySorter
- Direct Known Subclasses:
WeightedAshwoodEntitySorter
Implements dependency sorting algorithms for ObjEntities, DbEntities and
DataObjects. Presently it works for acyclic database schemas with possible
multi-reflexive tables.
- Since:
- 3.1
-
Field Summary
Modifier and TypeFieldDescriptionprotected Comparator
<DbEntity> protected EntityResolver
protected Comparator
<ObjEntity> protected Map
<DbEntity, List<DbRelationship>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildDigraph
(ObjEntity objEntity, List<E> objects, Function<E, Persistent> converter) protected void
Reindexes internal sorter without synchronization.protected Persistent
findReflexiveMaster
(Persistent object, ObjRelationship toOneRel, String targetEntityName) protected Comparator
<DbEntity> getDbEntityComparator
(boolean dependantFirst) protected Comparator
<ObjEntity> getObjEntityComparator
(boolean dependantFirst) protected String[]
getReflexiveRelationshipsNames
(ObjEntity objEntity) protected void
Reindexes internal sorter in a thread-safe manner.boolean
isReflexive
(DbEntity metadata) void
setEntityResolver
(EntityResolver entityResolver) Sets EntityResolver for this sorter.void
sortDbEntities
(List<DbEntity> dbEntities, boolean deleteOrder) Sorts a list of DbEntities.void
sortObjectsForEntity
(ObjEntity objEntity, List<?> objects, boolean deleteOrder) Sorts a list of objects belonging to the ObjEntity.protected <E> void
sortObjectsForEntity
(ObjEntity objEntity, List<E> objects, boolean deleteOrder, Function<E, Persistent> converter) void
sortObjEntities
(List<ObjEntity> objEntities, boolean deleteOrder) Sorts a list of ObjEntities.protected <E> boolean
topologicalSort
(List<E> data, Digraph<E, Boolean> graph, boolean reverse)
-
Field Details
-
entityResolver
-
components
-
reflexiveDbEntities
-
dbEntityComparator
-
objEntityComparator
-
-
Constructor Details
-
AshwoodEntitySorter
public AshwoodEntitySorter()
-
-
Method Details
-
indexSorter
protected void indexSorter()Reindexes internal sorter in a thread-safe manner. -
doIndexSorter
protected void doIndexSorter()Reindexes internal sorter without synchronization. -
setEntityResolver
Description copied from interface:EntitySorter
Sets EntityResolver for this sorter. All entities present in the resolver will be used to determine sort ordering.- Specified by:
setEntityResolver
in interfaceEntitySorter
- Since:
- 3.1
-
sortDbEntities
Description copied from interface:EntitySorter
Sorts a list of DbEntities.- Specified by:
sortDbEntities
in interfaceEntitySorter
-
sortObjEntities
Description copied from interface:EntitySorter
Sorts a list of ObjEntities.- Specified by:
sortObjEntities
in interfaceEntitySorter
-
sortObjectsForEntity
Description copied from interface:EntitySorter
Sorts a list of objects belonging to the ObjEntity.- Specified by:
sortObjectsForEntity
in interfaceEntitySorter
-
sortObjectsForEntity
protected <E> void sortObjectsForEntity(ObjEntity objEntity, List<E> objects, boolean deleteOrder, Function<E, Persistent> converter) -
buildDigraph
-
topologicalSort
-
getReflexiveRelationshipsNames
-
findReflexiveMaster
protected Persistent findReflexiveMaster(Persistent object, ObjRelationship toOneRel, String targetEntityName) -
getDbEntityComparator
- Specified by:
getDbEntityComparator
in interfaceEntitySorter
- Returns:
- comparator for
DbEntity
-
getObjEntityComparator
- Specified by:
getObjEntityComparator
in interfaceEntitySorter
- Returns:
- comparator for
ObjEntity
-
getDbEntityComparator
-
getObjEntityComparator
-
isReflexive
- Specified by:
isReflexive
in interfaceEntitySorter
- Parameters:
metadata
- to check- Returns:
- is entity has reflexive relationships
-