Examples of PathQueryNode


Examples of org.exoplatform.services.jcr.impl.core.query.PathQueryNode

      // pass to select, from, where, ...
      node.childrenAccept(this, root);

      // use //* if no path has been set
      PathQueryNode pathNode = root.getLocationNode();
      pathNode.setAbsolute(true);
      if (pathConstraints.size() == 0)
      {
         LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
         step.setNameTest(null);
         step.setIncludeDescendants(true);
         pathNode.addPathStep(step);
      }
      else
      {
         try
         {
            while (pathConstraints.size() > 1)
            {
               // merge path nodes
               MergingPathQueryNode path = null;
               for (Iterator it = pathConstraints.iterator(); it.hasNext();)
               {
                  path = (MergingPathQueryNode) it.next();
                  if (path.needsMerge())
                  {
                     break;
                  }
                  else
                  {
                     path = null;
                  }
               }
               if (path == null)
               {
                  throw new IllegalArgumentException("Invalid combination of jcr:path clauses");
               }
               else
               {
                  pathConstraints.remove(path);
                  MergingPathQueryNode[] paths =
                           (MergingPathQueryNode[]) pathConstraints.toArray(new MergingPathQueryNode[pathConstraints
                                    .size()]);
                  paths = path.doMerge(paths);
                  pathConstraints.clear();
                  pathConstraints.addAll(Arrays.asList(paths));
               }
            }
         }
         catch (NoSuchElementException e)
         {
            throw new IllegalArgumentException("Invalid combination of jcr:path clauses", e);
         }
         MergingPathQueryNode path = (MergingPathQueryNode) pathConstraints.get(0);
         LocationStepQueryNode[] steps = path.getPathSteps();
         for (int i = 0; i < steps.length; i++)
         {
            LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
            step.setNameTest(steps[i].getNameTest());
            step.setIncludeDescendants(steps[i].getIncludeDescendants());
            step.setIndex(steps[i].getIndex());
            pathNode.addPathStep(step);
         }
      }

      if (constraintNode.getNumOperands() == 1)
      {
         // attach operand to last path step
         LocationStepQueryNode[] steps = pathNode.getPathSteps();
         steps[steps.length - 1].addPredicate(constraintNode.getOperands()[0]);
      }
      else if (constraintNode.getNumOperands() > 1)
      {
         // attach constraint to last path step
         LocationStepQueryNode[] steps = pathNode.getPathSteps();
         steps[steps.length - 1].addPredicate(constraintNode);
      }

      if (nodeTypeName != null)
      {
         // add node type constraint
         LocationStepQueryNode[] steps = pathNode.getPathSteps();
         NodeTypeQueryNode nodeType = factory.createNodeTypeQueryNode(steps[steps.length - 1], nodeTypeName);
         steps[steps.length - 1].addPredicate(nodeType);
      }

      return root;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.