Examples of ArrayQueryNode


Examples of org.sindice.siren.qparser.json.nodes.ArrayQueryNode

    final JsonNode value = node.path(CHILD_PROPERTY);
    if (!value.isArray()) {
      throw new ParseException("Invalid property'" + CHILD_PROPERTY + "': value is not an array");
    }

    final ArrayQueryNode arrayNode = new ArrayQueryNode();

    final Iterator<JsonNode> elements = value.getElements();
    while (elements.hasNext()) {
      final JsonNode element = elements.next();

      // parse occur
      final OccurPropertyParser occurParser = new OccurPropertyParser(element, field);
      Modifier mod = null;
      if (occurParser.isPropertyDefined()) {
        mod = occurParser.parse();
      }

      // check if there is either a node or a twig property and parse it
      QueryNode queryNode = null;
      if (element.has(NodePropertyParser.NODE_PROPERTY)) {
        final NodePropertyParser nodeParser = new NodePropertyParser(element, field);
        queryNode = nodeParser.parse();
      }
      if (element.has(TwigPropertyParser.TWIG_PROPERTY)) {
        final TwigPropertyParser twigParser = new TwigPropertyParser(element, field);
        queryNode = twigParser.parse();
      }

      // check if either a node or twig property has been defined
      if (queryNode == null) {
        throw new ParseException("Invalid property'" + CHILD_PROPERTY + "': object does not define a twig or node query");
      }

      // create a child query node and add it to the array query node
      arrayNode.add(new ChildQueryNode(queryNode, mod));
    }

    return arrayNode;
  }
View Full Code Here

Examples of org.sindice.siren.qparser.json.nodes.ArrayQueryNode

    final JsonNode value = node.path(DESCENDANT_PROPERTY);
    if (!value.isArray()) {
      throw new ParseException("Invalid property'" + DESCENDANT_PROPERTY + "': value is not an array");
    }

    final ArrayQueryNode arrayNode = new ArrayQueryNode();

    final Iterator<JsonNode> elements = value.getElements();
    while (elements.hasNext()) {
      final JsonNode element = elements.next();

      // parse occur
      final OccurPropertyParser occurParser = new OccurPropertyParser(element, field);
      Modifier mod = null;
      if (occurParser.isPropertyDefined()) {
        mod = occurParser.parse();
      }

      // parse level
      final LevelPropertyParser levelParser = new LevelPropertyParser(element, field);
      int level = -1;
      if (levelParser.isPropertyDefined()) {
        level = levelParser.parse();
      }

      // check if there is either a node or a twig property and parse it
      QueryNode queryNode = null;
      if (element.has(NodePropertyParser.NODE_PROPERTY)) {
        final NodePropertyParser nodeParser = new NodePropertyParser(element, field);
        queryNode = nodeParser.parse();
      }
      if (element.has(TwigPropertyParser.TWIG_PROPERTY)) {
        final TwigPropertyParser twigParser = new TwigPropertyParser(element, field);
        queryNode = twigParser.parse();
      }

      // check if either a node or twig property has been defined
      if (queryNode == null) {
        throw new ParseException("Invalid property'" + DESCENDANT_PROPERTY + "': one array object does not define a twig or node query");
      }

      // create a descendant query node and add it to the array query node
      arrayNode.add(new DescendantQueryNode(queryNode, mod, level));
    }

    return arrayNode;
  }
View Full Code Here

Examples of org.sindice.siren.qparser.json.nodes.ArrayQueryNode

    }

    final ChildPropertyParser childParser = new ChildPropertyParser(objectNode, field);
    childParser.setOptional(true);
    if (childParser.isPropertyDefined()) {
      final ArrayQueryNode arrayNode = childParser.parse();
      twigNode.add(arrayNode.getChildren());
    }

    final DescendantPropertyParser descendantParser = new DescendantPropertyParser(objectNode, field);
    descendantParser.setOptional(true);
    if (descendantParser.isPropertyDefined()) {
      final ArrayQueryNode arrayNode = descendantParser.parse();
      twigNode.add(arrayNode.getChildren());
    }

    return twigNode;
  }
View Full Code Here

Examples of org.sindice.siren.qparser.keyword.nodes.ArrayQueryNode

      this.queryNodeList = actualQueryNodeList;
      this.latestNodeVerified = false;
    }
    else if (node instanceof ArrayQueryNode) {
      final ArrayList<QueryNode> actualQueryNodeList = this.queryNodeList;
      final ArrayQueryNode arrayNode = (ArrayQueryNode) node;
      final List<QueryNode> children = arrayNode.getChildren();
      final List<QueryNode> newChildren = new ArrayList<QueryNode>();
      for (final QueryNode child : children) {
        // The unary modifier sets the occurrence of this value in the TwigQuery
        if (!(child instanceof ModifierQueryNode)) {
          newChildren.add(this.process(child));
        } else {
          newChildren.add(child);
        }
      }
      arrayNode.set(newChildren);
      actualQueryNodeList.add(arrayNode);
      this.queryNodeList = actualQueryNodeList;
      this.latestNodeVerified = false;
    }
    else if (node instanceof TopLevelQueryNode) {
View Full Code Here

Examples of org.sindice.siren.qparser.keyword.nodes.ArrayQueryNode

    }
    if (!(child instanceof WildcardNodeQueryNode)) {
      // Build the child operand
      final Object v = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
      if (v instanceof ArrayQuery) { // array of children nodes
        final ArrayQueryNode aqn = (ArrayQueryNode) child;
        final List<Query> children = ((ArrayQuery) v).getElements();
        for (int i = 0; i < children.size(); i++) {
          twigQuery.addChild((NodeQuery) children.get(i),
            NodeQueryBuilderUtil.getModifierValue(aqn.getChildren().get(i), NodeBooleanClause.Occur.MUST));
        }
      } else if (v instanceof Query) {
        final NodeQuery valQuery = (NodeQuery) v;
        twigQuery.addChild(valQuery, Occur.MUST);
      } else {
View Full Code Here

Examples of org.sindice.siren.qparser.keyword.nodes.ArrayQueryNode

implements StandardQueryBuilder {

  @Override
  public Query build(final QueryNode queryNode)
  throws QueryNodeException {
    final ArrayQueryNode arrayNode = (ArrayQueryNode) queryNode;
    final List<QueryNode> children = arrayNode.getChildren();
    final ArrayQuery arrayQuery = new ArrayQuery();

    for (final QueryNode child : children) {
      final Object v = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
      if (v == null) { // DummyNode such as the EmptyNodeQueryNode
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.