fri.util.database.jpa.tree.closuretable.uniqueconstraints
Class UniqueChildrenConstraintImpl

java.lang.Object
  extended by fri.util.database.jpa.tree.uniqueconstraints.AbstractUniqueTreeConstraintImpl<N>
      extended by fri.util.database.jpa.tree.uniqueconstraints.AbstractWholeTreeUniqueConstraintImpl<ClosureTableTreeNode>
          extended by fri.util.database.jpa.tree.closuretable.uniqueconstraints.UniqueWholeTreeConstraintImpl
              extended by fri.util.database.jpa.tree.closuretable.uniqueconstraints.UniqueChildrenConstraintImpl
All Implemented Interfaces:
UniqueTreeConstraint<ClosureTableTreeNode>

public class UniqueChildrenConstraintImpl
extends UniqueWholeTreeConstraintImpl

Accepts a single or a combination of several unique properties, and it checks if they are unique relative to its parent node. That means a property value can appear just once among siblings, but can appear in other child lists. Also performs the root uniqueness check if location requires that.

Author:
Fritz Ritzberger, 31.10.2012

Field Summary
 
Fields inherited from class fri.util.database.jpa.tree.uniqueconstraints.AbstractUniqueTreeConstraintImpl
shouldCheckRootsForUniqueness, uniquePropertyNames
 
Constructor Summary
UniqueChildrenConstraintImpl(java.lang.String[][] uniquePropertyNames, boolean shouldCheckRootsForUniqueness)
           
 
Method Summary
 boolean checkUniqueConstraint(java.util.List<ClosureTableTreeNode> nodes, TreeActionLocation<ClosureTableTreeNode> location)
          The implementation of this is expected to check the uniqueness of passed node(s).
 
Methods inherited from class fri.util.database.jpa.tree.closuretable.uniqueconstraints.UniqueWholeTreeConstraintImpl
appendNodeCheckingCondition, appendRootCheckingCondition, fromClause, getNodeTableAlias, getPathTableAlias
 
Methods inherited from class fri.util.database.jpa.tree.uniqueconstraints.AbstractUniqueTreeConstraintImpl
appendUniquenessConditions, appendUpdateCondition, beforeCheckUniqueness, checkUniqueChildrenConstraint, checkUniqueWholeTreeConstraint, equal, getDao, getNodeValueForProperty, getSession, isDifferent, isRootsCheck, nodeEntityName, pathEntityName, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniqueChildrenConstraintImpl

public UniqueChildrenConstraintImpl(java.lang.String[][] uniquePropertyNames,
                                    boolean shouldCheckRootsForUniqueness)
Method Detail

checkUniqueConstraint

public final boolean checkUniqueConstraint(java.util.List<ClosureTableTreeNode> nodes,
                                           TreeActionLocation<ClosureTableTreeNode> location)
The implementation of this is expected to check the uniqueness of passed node(s). Called by the DAO when addChild(), move() or copy() is performed. Mind that you must call treeDao.checkUniqueConstraint() explicitly when updating a node property, see explanation in header comment!.

Specified by:
checkUniqueConstraint in interface UniqueTreeConstraint<ClosureTableTreeNode>
Overrides:
checkUniqueConstraint in class AbstractWholeTreeUniqueConstraintImpl<ClosureTableTreeNode>
Parameters:
nodes - one (default) or more (copy/move only) entities that hold values to check for uniqueness at location, when list, the copied node will be first, then its sub-nodes.
location - the information where the pending modification is going to happen.
Returns:
false when unique constraint would be violated, else true.