public abstract class AbstractHierarchyDaoImpl<T extends IHierarchialReference> extends AbstractQueryableDaoImpl<T>
IHierarchialReference domain related common DAO method helpers| Modifier and Type | Field and Description |
|---|---|
static String |
FILTER_PARENTS
Special Query Attribute:
Filter out parent nodes under this parent
|
static String |
FILTER_PARENTS_IMMEDIATE
Special Query Attribute:
If filterParents is true then this attribute is used to check if we want to filter for immediate
|
protected org.apache.commons.collections.Transformer |
relEntitiesDelTransformer
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
emct, t| Constructor and Description |
|---|
AbstractHierarchyDaoImpl() |
AbstractHierarchyDaoImpl(Class<T> ref) |
| Modifier and Type | Method and Description |
|---|---|
void |
convert(IHierarchialReference entity,
Class to)
If we wish to transform an entity type we should perform the transformation and then the update.
|
Long |
delete(Collection<Long> ids,
String entityName) |
Long |
delete(Long id,
String entityName) |
protected int |
deleteSubHierarchy(String hierarchyCode,
String entityName,
org.apache.commons.collections.Transformer relatedEntitiesHierachyDelete)
Delete from the given hierarchy code onward (including the given code)
|
protected int |
deleteSubHierarchy(T rootNode,
String entityName,
org.apache.commons.collections.Transformer relatedEntitiesHierachyDelete)
Delete a root node and its children.
May throw an exception is there is a fault in the hierarchy or any node could not be deleted for some reason. |
protected javax.persistence.Query |
filterParents(T parent,
boolean immediate,
boolean count)
Return
List of nodes that are parents under the specified parent Node. |
protected String |
getLastChildHierarchyCode(T parent,
String entityName)
WARN : Code not written for multiple processes trying to get the Max for the same category; will lead to collision
or possibly return of a number already alloted to another process
|
List<T> |
getParents(T entity,
boolean includeThis,
String DEFAULT_ENTITY_NAME,
QueryOptimizer queryOptimizer,
String entityName) |
org.apache.commons.collections.Transformer |
getPersistTransformer()
Some dependent entities may depend on the core Entity and may need to be persisted/updated/cleaned with (after) it in the same save operation.
This accepts the Entity instance as an input |
org.apache.commons.collections.Transformer |
getRelEntitiesDelTransformer()
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
protected boolean |
isExistsAsParent(T node)
A quick check to see if the current node is a parent
|
Page<T> |
loadPage(Query<T> query) |
protected String |
makeSpaceForNodeInParent(T node,
T parent,
Integer sequence,
String entityName)
WARN : Code not written for multiple processes trying to get the Max for the same category; will lead to collision
or possibly return of a number already alloted to another process
|
void |
move(T entity,
T newParent,
Integer sequence,
String entityName) |
T |
save(T entity) |
void |
setPersistTransformer(org.apache.commons.collections.Transformer postPersistTransformer)
Some dependent entities may depend on the core Entity and may need to be persisted/updated/cleaned with (after) it in the same save operation.
This accepts the Entity instance as an input |
void |
setRelEntitiesDelTransformer(org.apache.commons.collections.Transformer relEntitiesDelTransformer)
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
protected void |
shiftHierarchy(String currentHierarchyCode,
String newHierarchyCode,
String entityName,
T parent)
Re-organizes the
IHierarchialReference.getHierarchy() code. |
protected void |
verifyHierarchy(T rootNode,
String entityName)
Validate a tree / sub-tree.
For a given node, it verifies if there is any hierarchy that has an alternate node with a conflicting hierarchy code. |
conditionConstruct, count, ensureRowIsEntity, ensureRowIsEntity, getEntityInstance, getQueryObject, query, query, queryPage, queryPagedelete, delete, getEntityManager, getNativeEntityName, load, load, paginate, query, query, setEntityManager, updateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdelete, delete, load, loadpublic static final String FILTER_PARENTS
public static final String FILTER_PARENTS_IMMEDIATE
protected org.apache.commons.collections.Transformer relEntitiesDelTransformer
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.protected String getLastChildHierarchyCode(T parent, String entityName)
parent - @nullable true (if null then it will add to root)entityName - as String - Table name : to support native queryprotected boolean isExistsAsParent(T node)
@Transactional(readOnly=false) protected String makeSpaceForNodeInParent(T node, T parent, Integer sequence, String entityName)
node - being shiftedparent - @nullable true if IHierarchialReference.ROOTsequence - as Integer (to position within parent) @nullable falseentityName - as String (Table or Entity name , same as this#getLastChildHierarchyCode@Transactional(readOnly=true) protected javax.persistence.Query filterParents(T parent, boolean immediate, boolean count)
List of nodes that are parents under the specified parent Node. IHierarchialReference.getId() or IHierarchialReference.getHierarchy(); immediate is false.
parent - as Timmediate - as boolean; if true will fetch only parents immediately under the specified parententityName - count - true will return the counts@Transactional(readOnly=false) protected void shiftHierarchy(String currentHierarchyCode, String newHierarchyCode, String entityName, T parent)
IHierarchialReference.getHierarchy() code. Note: it does not change parent.currentHierarchyCode - as String of the node to be Shifted @nullable true, for any content (like New) that does not require shifting - User Case : IgnorenewHierarchyCode - as String, to the location this will shift (will not check for conflicts, use getLastChildHierarchyCode(IHierarchialReference, String)
or makeSpaceForNodeInParent(IHierarchialReference, IHierarchialReference, Integer, String) or HierarchyHelper.getNewHierarchySequence(String, String, int, List) for that.entityName - parent - @nullable true; Future Use@Transactional(readOnly=true) protected void verifyHierarchy(T rootNode, String entityName) throws Exception
Exception@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
protected int deleteSubHierarchy(String hierarchyCode,
String entityName,
org.apache.commons.collections.Transformer relatedEntitiesHierachyDelete)
hierarchyCode - entityName - as StringrelatedEntitiesHierachyDelete - as Transformer, that will be passed hierarchy code and based on that it will delete all concerned records from related entities@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
protected int deleteSubHierarchy(T rootNode,
String entityName,
org.apache.commons.collections.Transformer relatedEntitiesHierachyDelete)
throws Exception
rootNode - entityName - as StringrelatedEntitiesHierachyDelete - as Transformer, that will be passed hierarchy code and based on that it will delete all concerned records from related entitiesException@Transactional(readOnly=false) public void convert(IHierarchialReference entity, Class to)
InheritanceType.SINGLE_TABLE or oen where there is a shared DiscriminatorValue
public Long delete(Collection<Long> ids, String entityName)
public T save(T entity)
save in interface GenericDao<T extends IHierarchialReference>save in class GenericDaoImpl<T extends IHierarchialReference>public void move(T entity, T newParent, Integer sequence, String entityName) throws Exception
entity - as Entity type newParent - as Entity type sequence - as IntegerentityName - as StringExceptionpublic List<T> getParents(T entity, boolean includeThis, String DEFAULT_ENTITY_NAME, QueryOptimizer queryOptimizer, String entityName)
public org.apache.commons.collections.Transformer getRelEntitiesDelTransformer()
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.public void setRelEntitiesDelTransformer(org.apache.commons.collections.Transformer relEntitiesDelTransformer)
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.public org.apache.commons.collections.Transformer getPersistTransformer()
public void setPersistTransformer(org.apache.commons.collections.Transformer postPersistTransformer)
Copyright © 2018. All rights reserved.