|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfri.util.database.jpa.tree.AbstractTreeDao<NestedSetsTreeNode>
fri.util.database.jpa.tree.nestedsets.NestedSetsTreeDao
fri.util.database.jpa.tree.nestedsets.TemporalNestedSetsTreeDao
public class TemporalNestedSetsTreeDao
DAO extension that allows to historicize entities instead of deleting them.
Following methods must be overridden for another historization-mechanism than the default validFrom and validTo properties:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface fri.util.database.jpa.tree.TreeDao |
---|
TreeDao.CopiedNodeRenamer<N extends TreeNode> |
Field Summary |
---|
Fields inherited from class fri.util.database.jpa.tree.AbstractTreeDao |
---|
session |
Fields inherited from interface fri.util.database.jpa.tree.TreeDao |
---|
UNDEFINED_POSITION |
Constructor Summary | |
---|---|
TemporalNestedSetsTreeDao(java.lang.Class<? extends NestedSetsTreeNode> targetEntityClass,
java.lang.String validFromPropertyName,
java.lang.String validToPropertyName,
DbSession session)
|
|
TemporalNestedSetsTreeDao(java.lang.Class<? extends NestedSetsTreeNode> targetEntityClass,
java.lang.String targetEntityName,
java.lang.String validFromPropertyName,
java.lang.String validToPropertyName,
DbSession session)
|
Method Summary | |
---|---|
protected void |
assignInvalidity(java.lang.String tableAlias,
java.lang.StringBuilder updateText,
java.util.List<java.lang.Object> parameters)
Called when removing nodes. |
protected void |
assignValidity(java.lang.String tableAlias,
java.lang.StringBuilder updateText,
java.util.List<java.lang.Object> parameters)
Called when unremoving nodes. |
protected void |
beforeFindQuery(java.lang.String tableAlias,
java.lang.StringBuilder queryText,
java.util.List<java.lang.Object> parameters,
boolean whereWasAppended)
Overridden to search only nodes that were not historicized. |
java.util.List<NestedSetsTreeNode> |
findRemoved(NestedSetsTreeNode parent,
java.util.Map<java.lang.String,java.lang.Object> criteria)
|
java.util.List<NestedSetsTreeNode> |
findValidDirectChildren(java.util.List<NestedSetsTreeNode> subNodes)
Use this to retrieve children lists that do not contain removed nodes from trees returned by getFullTreeCacheable() . |
java.util.List<NestedSetsTreeNode> |
getAllRoots()
|
protected java.util.List<NestedSetsTreeNode> |
getChildListForInsertion(NestedSetsTreeNode parent)
Overridden to return children including invalid ones. |
java.util.List<NestedSetsTreeNode> |
getChildren(NestedSetsTreeNode parent)
Overridden because super.getChildren() would not work with a sub-tree list that contains nodes with left/right indexes that have gaps because historicized nodes are not contained. |
java.util.List<NestedSetsTreeNode> |
getFullTreeCacheable(NestedSetsTreeNode node)
|
protected java.util.List<NestedSetsTreeNode> |
getSubTreeDepthFirstForCopy(NestedSetsTreeNode nodeToCopy)
Overridden to include removed nodes into copy-list, else inconsistent left/right numbers would occur. |
protected java.lang.String |
getValidFromPropertyName()
Temporal extension. |
protected java.lang.String |
getValidToPropertyName()
Temporal extension. |
boolean |
isLeaf(NestedSetsTreeNode node)
Overridden to read the subtree when super returns false, because historicized nodes occupy left and right indexes. |
protected boolean |
isNextChild(int nextChildLeft,
NestedSetsTreeNode node,
int currentChildRight,
java.util.List<NestedSetsTreeNode> subNodes,
int currentIndex)
Overridden to bridge index gaps that occur when nodes have been historicized. |
protected boolean |
isValidFilterChild(NestedSetsTreeNode node)
Overridden to filter out historicized children on findDirectChildren(). |
protected void |
remove(NestedSetsTreeNode node,
int removedNodesCount)
Overridden to historicize children. |
void |
removeAll()
Overridden to historicize roots instead of removing them physically. |
void |
removeAllPhysically()
Physically deletes everything, all roots and the trees below them. |
void |
removeHistoricizedTreesPhysically()
Physically deletes all historicized tree nodes in all roots, including their sub-nodes. |
void |
removePhysically(NestedSetsTreeNode node)
Physically deletes the tree under given node, including the node itself. |
int |
size(NestedSetsTreeNode node)
Overridden to always read the subtree, because historicized nodes occupy left and right indexes. |
void |
unremove(NestedSetsTreeNode node)
Recovers the given removed (historicized) node, including all sub-nodes. |
Methods inherited from class fri.util.database.jpa.tree.nestedsets.NestedSetsTreeDao |
---|
addChild, addChildAt, addChildBefore, copy, copyBefore, copyOrMovePreconditions, copyTo, copyToBeRoot, createRoot, find, find, findDirectChildren, findSubTree, getChildCount, getLevel, getParent, getPath, getRoot, getRoots, getTree, getTreeCacheable, isChildOf, isEqualToOrChildOf, isRoot, move, moveBefore, moveTo, moveToBeRoot, remove, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fri.util.database.jpa.tree.TreeDao |
---|
addChild, addChildAt, addChildBefore, checkUniqueConstraint, copy, copyBefore, copyTo, copyToBeRoot, createRoot, find, find, findDirectChildren, findSubTree, getChildCount, getLevel, getParent, getPath, getRoot, getRoots, getTree, getTreeCacheable, isChildOf, isEqualToOrChildOf, isPersistent, isRoot, move, moveBefore, moveTo, moveToBeRoot, remove, setCheckUniqueConstraintOnUpdate, setCopiedNodeRenamer, setUniqueTreeConstraint, update |
Constructor Detail |
---|
public TemporalNestedSetsTreeDao(java.lang.Class<? extends NestedSetsTreeNode> targetEntityClass, java.lang.String validFromPropertyName, java.lang.String validToPropertyName, DbSession session)
validFromPropertyName
- the name of the temporal valid-from property, can be null.validToPropertyName
- the name of the temporal valid-to property, can be null when append* and assign* are overridden.public TemporalNestedSetsTreeDao(java.lang.Class<? extends NestedSetsTreeNode> targetEntityClass, java.lang.String targetEntityName, java.lang.String validFromPropertyName, java.lang.String validToPropertyName, DbSession session)
validFromPropertyName
- the name of the temporal valid-from property, can be null.validToPropertyName
- the name of the temporal valid-to property, can be null when append* and assign* are overridden.Method Detail |
---|
public int size(NestedSetsTreeNode node)
size
in interface TreeDao<NestedSetsTreeNode>
size
in class NestedSetsTreeDao
public boolean isLeaf(NestedSetsTreeNode node)
isLeaf
in interface TreeDao<NestedSetsTreeNode>
isLeaf
in class NestedSetsTreeDao
public java.util.List<NestedSetsTreeNode> getChildren(NestedSetsTreeNode parent)
getChildren
in interface TreeDao<NestedSetsTreeNode>
getChildren
in class NestedSetsTreeDao
public void removeAll()
removeAll
in interface TreeDao<NestedSetsTreeNode>
removeAll
in class NestedSetsTreeDao
public java.util.List<NestedSetsTreeNode> findRemoved(NestedSetsTreeNode parent, java.util.Map<java.lang.String,java.lang.Object> criteria)
findRemoved
in interface TemporalTreeDao<NestedSetsTreeNode>
public java.util.List<NestedSetsTreeNode> getAllRoots()
getAllRoots
in interface TemporalTreeDao<NestedSetsTreeNode>
public java.util.List<NestedSetsTreeNode> getFullTreeCacheable(NestedSetsTreeNode node)
getFullTreeCacheable
in interface TemporalTreeDao<NestedSetsTreeNode>
public void unremove(NestedSetsTreeNode node)
unremove
in interface TemporalTreeDao<NestedSetsTreeNode>
public void removeHistoricizedTreesPhysically()
removeHistoricizedTreesPhysically
in interface TemporalTreeDao<NestedSetsTreeNode>
public void removeAllPhysically()
removeAllPhysically
in interface TemporalTreeDao<NestedSetsTreeNode>
public void removePhysically(NestedSetsTreeNode node)
removePhysically
in interface TemporalTreeDao<NestedSetsTreeNode>
public java.util.List<NestedSetsTreeNode> findValidDirectChildren(java.util.List<NestedSetsTreeNode> subNodes)
getFullTreeCacheable()
.
Use findDirectChildren()
on a fullTreeCacheable to retrieve children lists that
also contain removed nodes. The difference of both would be the removed children.
findValidDirectChildren
in interface TemporalTreeDao<NestedSetsTreeNode>
subNodes
- the sub-tree to retrieve children from, containing parent at first position.
protected final void beforeFindQuery(java.lang.String tableAlias, java.lang.StringBuilder queryText, java.util.List<java.lang.Object> parameters, boolean whereWasAppended)
beforeFindQuery
in class NestedSetsTreeDao
protected java.util.List<NestedSetsTreeNode> getSubTreeDepthFirstForCopy(NestedSetsTreeNode nodeToCopy)
getSubTreeDepthFirstForCopy
in class NestedSetsTreeDao
protected final boolean isValidFilterChild(NestedSetsTreeNode node)
isValidFilterChild
in class NestedSetsTreeDao
protected final java.util.List<NestedSetsTreeNode> getChildListForInsertion(NestedSetsTreeNode parent)
getChildListForInsertion
in class NestedSetsTreeDao
protected final void remove(NestedSetsTreeNode node, int removedNodesCount)
remove
in class NestedSetsTreeDao
protected boolean isNextChild(int nextChildLeft, NestedSetsTreeNode node, int currentChildRight, java.util.List<NestedSetsTreeNode> subNodes, int currentIndex)
isNextChild
in class NestedSetsTreeDao
protected void assignInvalidity(java.lang.String tableAlias, java.lang.StringBuilder updateText, java.util.List<java.lang.Object> parameters)
tableAlias
- the alias of the table containing the validTo property, without trailing dot.updateText
- the pending JPQL query text removing invalid nodes.parameters
- the positional arguments for the pending query.protected void assignValidity(java.lang.String tableAlias, java.lang.StringBuilder updateText, java.util.List<java.lang.Object> parameters)
tableAlias
- the alias of the table containing the validTo property, without trailing dot.updateText
- the pending JPQL query text unremoving nodes.parameters
- the positional arguments for the pending query.protected final java.lang.String getValidFromPropertyName()
AbstractTreeDao
getValidFromPropertyName
in class AbstractTreeDao<NestedSetsTreeNode>
protected final java.lang.String getValidToPropertyName()
AbstractTreeDao
getValidToPropertyName
in class AbstractTreeDao<NestedSetsTreeNode>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |