Package org.jasig.portal.layout.restrictions.alm

Examples of org.jasig.portal.layout.restrictions.alm.PriorityRestriction


                break;
            }
              // Adding the user priority restriction
              if ( nodeDesc != null ) {
               int[] priorityRange = UserPriorityManager.getPriorityRange(person);     
         PriorityRestriction restriction = (PriorityRestriction) UserLayoutRestrictionFactory.createRestriction(RestrictionTypes.PRIORITY_RESTRICTION);
         restriction.setRestriction(priorityRange[0],priorityRange[1]);
               nodeDesc.addRestriction(restriction);
              }
            return nodeDesc;   
    }
View Full Code Here


     * Return a priority restriction for the given node.
     * @return a <code>PriorityRestriction</code> object
     * @exception PortalException if an error occurs
     */
  public static PriorityRestriction getPriorityRestriction( ALNode node ) throws PortalException {
     PriorityRestriction priorRestriction = getPriorityRestriction(node,IUserLayoutRestriction.LOCAL_RESTRICTION_PATH);
     if ( priorRestriction == null ) {
       priorRestriction = (PriorityRestriction)
         UserLayoutRestrictionFactory.createRestriction(RestrictionTypes.PRIORITY_RESTRICTION,"0-"+java.lang.Integer.MAX_VALUE);
     }
     return priorRestriction;
View Full Code Here

     */
  protected synchronized boolean changeSiblingNodesPriorities(ALNode node, String parentNodeId, String nextNodeId ) throws PortalException {
    ALNode firstNode = null, nextNode = null;
      String firstNodeId = null;
      int priority = 0, nextPriority = 0, prevPriority = 0, range[] = null, prevRange[] = null, nextRange[] = null;
      PriorityRestriction priorityRestriction = null;
      String nodeId = node.getId();

      ALFolder parent = getLayoutFolder(parentNodeId);
      if ( parentNodeId != null ) {
        firstNodeId = parent.getFirstChildNodeId();
        // if the node is equal the first node in the sibling line we get the next node
        if ( nodeId.equals(firstNodeId) )
          firstNodeId = node.getNextNodeId();
        if ( firstNodeId == null ) return true;
      } else
         return false;

      firstNode = getLayoutNode(firstNodeId);

      if ( nextNodeId != null ) {
        nextNode = getLayoutNode(nextNodeId);
        nextPriority = nextNode.getPriority();
        priorityRestriction = getPriorityRestriction(nextNode);
        nextRange = priorityRestriction.getRange();
      }


      priority = node.getPriority();
      priorityRestriction = getPriorityRestriction(node);
      range = priorityRestriction.getRange();

      // If we add a new node to the beginning of the sibling line
      if ( firstNodeId.equals(nextNodeId) ) {

        if ( range[1] <= nextRange[0] ) return false;

        if ( priority > nextPriority ) return true;

        if ( range[1] > nextPriority ) {
           node.setPriority(range[1]);
           return true;
        }

        if ( (nextPriority+1) <= range[1] && (nextPriority+1) >= range[0] ) {
           node.setPriority(nextPriority+1);
           return true;
        }
      }

      // If we add a new node to the end of the sibling line
      if ( nextNode == null ) {

        // Getting the last node
        ALNode lastNode = getLastSiblingNode(firstNodeId);

        int lastPriority = lastNode.getPriority();
        PriorityRestriction lastPriorityRestriction = getPriorityRestriction(lastNode);
        int[] lastRange = lastPriorityRestriction.getRange();


        if ( range[0] >= lastRange[1] ) return false;

        if ( priority < lastPriority return true;

        if ( range[0] < lastPriority ) {
           node.setPriority(range[0]);
           return true;
        }

        if ( (lastPriority-1) <= range[1] && (lastPriority-1) >= range[0] ) {
           node.setPriority(range[0]);
           return true;
        }

      }


      // If we add a new node in a general case
      if ( nextNode != null && !nextNode.equals(firstNode) && !nodeId.equals(nextNodeId) ) {

        // Getting the last node
        ALNode prevNode = getLayoutNode(nextNode.getPreviousNodeId());

        prevPriority = prevNode.getPriority();
        PriorityRestriction lastPriorityRestriction = getPriorityRestriction(prevNode);
        prevRange = lastPriorityRestriction.getRange();


        if ( range[1] <= nextRange[0] || range[0] >= prevRange[1] ) return false;

        if ( priority < prevPriority && priority > nextPriority ) return true;
View Full Code Here

                    break readLayout;
                   }
                } //end else

                // Setting up the priority values based on the appropriate priority restrictions
                PriorityRestriction priorityRestriction = AggregatedLayoutManager.getPriorityRestriction(node);
                if ( priorityRestriction != null ) {
                 int priority = node.getPriority();
                 int[] range = priorityRestriction.getRange();

                 int newPriority = priority;
                 if ( range[0] > priority )
                     newPriority = range[0];
                 else if ( range[1] < priority )
View Full Code Here

                    break readLayout;
                   }
                } //end else

                // Setting up the priority values based on the appropriate priority restrictions
                PriorityRestriction priorityRestriction = AggregatedLayoutManager.getPriorityRestriction(node);
                if ( priorityRestriction != null ) {
                 int priority = node.getPriority();
                 int[] range = priorityRestriction.getRange();

                 int newPriority = priority;
                 if ( range[0] > priority )
                     newPriority = range[0];
                 else if ( range[1] < priority )
View Full Code Here

        IUserLayoutRestriction restriction = (IUserLayoutRestriction ) e.nextElement();
         AttributesImpl paramAttrs = new AttributesImpl();
         paramAttrs.addAttribute("","path","path","CDATA",restriction.getRestrictionPath());
         // we have to re-scale the priority restriction for the UI
         if ( restriction.getName().equals(RestrictionTypes.PRIORITY_RESTRICTION) ) {
          PriorityRestriction priorRestriction = (PriorityRestriction) restriction;
          paramAttrs.addAttribute("","value","value","CDATA",((int)priorRestriction.getMinValue()/IAggregatedUserLayoutManager.PRIORITY_COEFF)+"-"+
                                                             ((int)priorRestriction.getMaxValue()/IAggregatedUserLayoutManager.PRIORITY_COEFF));
         } else
          paramAttrs.addAttribute("","value","value","CDATA",restriction.getRestrictionExpression());

         paramAttrs.addAttribute("","type","type","CDATA",restriction.getName());
         contentHandler.startElement("",RESTRICTION,RESTRICTION,paramAttrs);
View Full Code Here

TOP

Related Classes of org.jasig.portal.layout.restrictions.alm.PriorityRestriction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.