org.jasig.portal.layout.dlm
Class PositionManager

java.lang.Object
  extended by org.jasig.portal.layout.dlm.PositionManager

public class PositionManager
extends java.lang.Object

Applies and updates position specifiers for child nodes in the composite layout.

Since:
uPortal 2.5
Version:
$Revision: 1.7 $ $Date: 2005/05/04 19:53:20 $

Nested Class Summary
(package private) static class PositionManager.NodeInfoComparator
           
 
Field Summary
private static RDBMDistributedLayoutStore dls
           
private static org.apache.commons.logging.Log LOG
           
static java.lang.String RCS_ID
           
 
Constructor Summary
PositionManager()
           
 
Method Summary
(package private) static void adjustPositionSet(java.util.ArrayList order, org.w3c.dom.Element positionSet, IntegrationResult result)
          This method trims down the position set to the position directives on the node info elements still having a position directive.
(package private) static void applyLowerPrecedence(java.util.ArrayList order, org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet)
          This method is responsible for preventing nodes with lower precedence from being located to the left (lower sibling order) of nodes having a higher precedence and moveAllowed="false".
(package private) static void applyNoHopping(java.util.ArrayList order, org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet)
          This method is responsible for preventing nodes with identical precedence in the same parent from hopping over each other so that a layout fragment can lock two tabs that are next to each other and they can only be separated by tabs with higher precedence.
(package private) static void applyNoReparenting(java.util.ArrayList order, org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet)
          This method scans through the nodes in the ordered list and identifies those that are not in the passed in compViewParent.
(package private) static void applyOrdering(java.util.ArrayList order, org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet)
          This method assembles in the passed in order object a list of NodeInfo objects ordered first by those specified in the position set and whose nodes still exist in the composite view and then by any remaining children in the compViewParent.
(package private) static void applyPositions(org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet, IntegrationResult result)
          This method and ones that it delegates to have the responsibility of organizing the child nodes of the passed in composite view parent node according to the order specified in the passed in position set and return via the passed in result set whether the personal layout fragment (one portion of which is the position set) or the incoporated layouts fragment (one portion of which is the compViewParent) were changed.
(package private) static void applyToNodes(java.util.ArrayList order, org.w3c.dom.Element compViewParent)
          This method applies the ordering specified in the passed in order list to the child nodes of the compViewParent.
private static org.w3c.dom.Element createAndAppendPosition(java.lang.String elementID, org.w3c.dom.Element positions, IPerson person)
          Create, append to the passed in position set, and return a position element that references the passed in elementID.
(package private) static void evaluateAndApply(java.util.ArrayList order, org.w3c.dom.Element compViewParent, org.w3c.dom.Element positionSet, IntegrationResult result)
          This method determines if applying all of the positioning rules and restrictions ended up making changes to the compViewParent or the original position set.
private static RDBMDistributedLayoutStore getDLS()
          Hands back the single instance of RDBMDistributedLayoutStore.
private static org.w3c.dom.Element getPositionSet(org.w3c.dom.Element plfParent, IPerson person, boolean create)
          This method locates the position set element in the child list of the passed in plfParent or if not found it will create one automatically and return it if the passed in create flag is true.
(package private) static boolean hasAffectOnCVP(java.util.ArrayList order, org.w3c.dom.Element compViewParent)
          This method compares the children by id in the order list with the order in the compViewParent's ui visible children and returns true if the ordering differs indicating that the positioning if needed.
(package private) static boolean isIllegalHoppingSpecified(java.util.ArrayList order)
          This method determines if any illegal hopping is being specified.
private static boolean isNotReparentable(NodeInfo ni)
          Return true if the passed in node or any of its up-stream (higher index siblings have moveAllowed="false".
static void updatePositionSet(org.w3c.dom.Element compViewParent, org.w3c.dom.Element plfParent, IPerson person)
          This method updates the positions recorded in a position set to reflect the ids of the nodes in the composite view of the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RCS_ID

public static final java.lang.String RCS_ID
See Also:
Constant Field Values

LOG

private static org.apache.commons.logging.Log LOG

dls

private static RDBMDistributedLayoutStore dls
Constructor Detail

PositionManager

public PositionManager()
Method Detail

getDLS

private static RDBMDistributedLayoutStore getDLS()
Hands back the single instance of RDBMDistributedLayoutStore. There is already a method for aquiring a single instance of the configured layout store so we delegate over there so that all references refer to the same instance. This method is solely for convenience so that we don't have to keep calling UserLayoutStoreFactory and casting the resulting class.


applyPositions

static void applyPositions(org.w3c.dom.Element compViewParent,
                           org.w3c.dom.Element positionSet,
                           IntegrationResult result)
                    throws PortalException
This method and ones that it delegates to have the responsibility of organizing the child nodes of the passed in composite view parent node according to the order specified in the passed in position set and return via the passed in result set whether the personal layout fragment (one portion of which is the position set) or the incoporated layouts fragment (one portion of which is the compViewParent) were changed. This may also include pulling nodes in from other parents under certain circumstances. For example, if allowed a user can move nodes that are not part of their personal layout fragment or PLF; the UI elements that they own. These node do not exist in their layout in the database but instead are merged in with their owned elements at log in and other times. So to move them during subsequent merges a position set can contain a position directive indicating the id of the node to be moved into a specific position in the sibling list and that well may refer to a node not in the sibling list to begin with. If the node no longer exists in the composite view then that position directive can safely be discarded. Positioning is meant to preserve as much as possible the user's specified ordering of user interface elements but always respecting movement restrictions placed on those elements that are incorporated by their owners. So the following rules apply from most important to least. 1) nodes with moveAllowed="false" prevent nodes of lower precedence from being to their left or higher with left or higher defined as having a lower index in the sibling list. (applyLowerPrecRestriction) 2) nodes with moveAllowed="false" prevent nodes of equal precedence from moving from one side of this node to the other from their position as found in the compViewParent initially and prevents nodes with the same precedence from moving from other parents into this parent prior to the restricted node. Prior to implies a lower sibling index. (applyHoppingRestriction) 3) nodes with moveAllowed="false" prevent nodes of equal precedence lower in the sibling list from being reparented. (ie: moving to another parent) However, they can be deleted. (applyReparentingCheck) 4) nodes should be ordered as much as possible in the order specified by the user but in view of the above conditions. So if a user has moved nodes thus specifying some order and the owner of some node in that set then locks one of those nodes some of those nodes will have to move back to their orinial positions to conform with the rules above but for the remaining nodes they should be found in the same relative order specified by the user. (getOrder) 5) nodes not included in the order specified by the user (ie: nodes added since the user last ordered them) should maintain their relative order as much as possible and be appended to the end of the sibling list after all others rules have been applied. (getOrder) Each of these rules is applied by a call to a method 5 being first and 1 being last so that 1 has the highest precedence and last say. Once the final ordering is specified then it is applied to the children of the compViewParent and returned.

Throws:
PortalException

evaluateAndApply

static void evaluateAndApply(java.util.ArrayList order,
                             org.w3c.dom.Element compViewParent,
                             org.w3c.dom.Element positionSet,
                             IntegrationResult result)
                      throws PortalException
This method determines if applying all of the positioning rules and restrictions ended up making changes to the compViewParent or the original position set. If changes are applicable to the CVP then they are applied. If the position set changed then the original stored in the PLF is updated.

Throws:
PortalException

adjustPositionSet

static void adjustPositionSet(java.util.ArrayList order,
                              org.w3c.dom.Element positionSet,
                              IntegrationResult result)
This method trims down the position set to the position directives on the node info elements still having a position directive. Any directives that violated restrictions were removed from the node info objects so the position set should be made to match the order of those still having one.


hasAffectOnCVP

static boolean hasAffectOnCVP(java.util.ArrayList order,
                              org.w3c.dom.Element compViewParent)
This method compares the children by id in the order list with the order in the compViewParent's ui visible children and returns true if the ordering differs indicating that the positioning if needed.


applyToNodes

static void applyToNodes(java.util.ArrayList order,
                         org.w3c.dom.Element compViewParent)
This method applies the ordering specified in the passed in order list to the child nodes of the compViewParent. Nodes specified in the list but located elsewhere are pulled in.


applyLowerPrecedence

static void applyLowerPrecedence(java.util.ArrayList order,
                                 org.w3c.dom.Element compViewParent,
                                 org.w3c.dom.Element positionSet)
This method is responsible for preventing nodes with lower precedence from being located to the left (lower sibling order) of nodes having a higher precedence and moveAllowed="false".


applyNoHopping

static void applyNoHopping(java.util.ArrayList order,
                           org.w3c.dom.Element compViewParent,
                           org.w3c.dom.Element positionSet)
This method is responsible for preventing nodes with identical precedence in the same parent from hopping over each other so that a layout fragment can lock two tabs that are next to each other and they can only be separated by tabs with higher precedence. If this situation is detected then the positioning of all nodes currently in the compViewParent is left as they are found in the CVP with any nodes brought in from other parents appended at the end with their relative order preserved.


isIllegalHoppingSpecified

static boolean isIllegalHoppingSpecified(java.util.ArrayList order)
This method determines if any illegal hopping is being specified. To determine if the positioning is specifying an ordering that will result in hopping I need to determine for each node n in the list if any of the nodes to be positioned to its right currently lie to its left in the CVP and have moveAllowed="false" and have the same precedence or if any of the nodes to be positioned to its left currently lie to its right in the CVP and have moveAllowed="false" and have the same precedence.


applyNoReparenting

static void applyNoReparenting(java.util.ArrayList order,
                               org.w3c.dom.Element compViewParent,
                               org.w3c.dom.Element positionSet)
This method scans through the nodes in the ordered list and identifies those that are not in the passed in compViewParent. For those it then looks in its current parent and checks to see if there are any down- stream (higher sibling index) siblings that have moveAllowed="false". If any such sibling is found then the node is not allowed to be reparented and is removed from the list.


isNotReparentable

private static boolean isNotReparentable(NodeInfo ni)
Return true if the passed in node or any of its up-stream (higher index siblings have moveAllowed="false".


applyOrdering

static void applyOrdering(java.util.ArrayList order,
                          org.w3c.dom.Element compViewParent,
                          org.w3c.dom.Element positionSet)
This method assembles in the passed in order object a list of NodeInfo objects ordered first by those specified in the position set and whose nodes still exist in the composite view and then by any remaining children in the compViewParent.


updatePositionSet

public static void updatePositionSet(org.w3c.dom.Element compViewParent,
                                     org.w3c.dom.Element plfParent,
                                     IPerson person)
                              throws PortalException
This method updates the positions recorded in a position set to reflect the ids of the nodes in the composite view of the layout. Any position nodes already in existence are reused to reduce database interaction needed to generate a new ID attribute. If any are left over after updating those position elements are removed. If no position set existed a new one is created for the parent. If no ILF nodes are found in the parent node then the position set as a whole is reclaimed.

Throws:
PortalException

getPositionSet

private static org.w3c.dom.Element getPositionSet(org.w3c.dom.Element plfParent,
                                                  IPerson person,
                                                  boolean create)
                                           throws PortalException
This method locates the position set element in the child list of the passed in plfParent or if not found it will create one automatically and return it if the passed in create flag is true.

Throws:
PortalException

createAndAppendPosition

private static org.w3c.dom.Element createAndAppendPosition(java.lang.String elementID,
                                                           org.w3c.dom.Element positions,
                                                           IPerson person)
                                                    throws PortalException
Create, append to the passed in position set, and return a position element that references the passed in elementID.

Throws:
PortalException