Package org.sindice.siren.qparser.keyword.nodes

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


  }

  @Test
  public void testTwigQueryNodeParent()
  throws Exception {
    final TwigQueryNode twig = new TwigQueryNode(new WildcardNodeQueryNode(),
                                                 new WildcardNodeQueryNode());
    final FieldQueryNode term = new FieldQueryNode("field", "term", 0, 4);
    assertTrue(term.getParent() == null);
    assertEquals(twig, twig.getRoot().getParent());
    assertEquals(twig, twig.getChild().getParent());
    twig.setRoot(term);
    twig.setChild(term);
    assertEquals(twig, twig.getRoot().getParent());
    assertEquals(twig, twig.getChild().getParent());
  }
View Full Code Here


  @Override
  protected QueryNode postProcessNode(final QueryNode node)
  throws QueryNodeException {
    if (node instanceof TwigQueryNode) {
      final TwigQueryNode twig = (TwigQueryNode) node;
      if (twig.getChild() instanceof WildcardNodeQueryNode &&
          twig.getRoot() instanceof WildcardNodeQueryNode) {
        throw new QueryNodeException(new MessageImpl("Twig with both root and child empty is not allowed."));
      }
    }
    return node;
  }
View Full Code Here

      this.queryNodeList = actualQueryNodeList;
      this.latestNodeVerified = false;
    }
    else if (node instanceof TwigQueryNode) {
      final ArrayList<QueryNode> actualQueryNodeList = this.queryNodeList;
      final TwigQueryNode twigNode = (TwigQueryNode) node;
      final QueryNode root = twigNode.getRoot();
      final QueryNode child = twigNode.getChild();
      if (!(root instanceof WildcardNodeQueryNode)) { // the root is not empty
        twigNode.setRoot(this.process(root));
      }
      if (!(child instanceof WildcardNodeQueryNode)) { // the child is not empty
        twigNode.setChild(this.process(child));
      }
      actualQueryNodeList.add(twigNode);
      this.queryNodeList = actualQueryNodeList;
      this.latestNodeVerified = false;
    }
View Full Code Here

    // parent twig query
    else if (node instanceof TwigQueryNode) {
      nbTwigs++;
      if (nbTwigs == 1) {
        // Set the json:field datatype on the top level node only
        final TwigQueryNode twig = (TwigQueryNode) node;
        twig.getRoot().setTag(DatatypeQueryNode.DATATYPE_TAGID, JSONDatatype.JSON_FIELD);
      }
    }
    // A datatype is being used
    else if (datatype != null) {
      node.setTag(DatatypeQueryNode.DATATYPE_TAGID, datatype);
View Full Code Here

      // Set the ROOT level of the query
      /*
       * When adding nested TwigQueries, their root level is set to the current
       * Twig level + 1. See {@link TwigQuery#addChild}.
       */
      final TwigQueryNode twigNode = (TwigQueryNode) node;
      twigNode.setRootLevel(root);
    }
    return node;
  }
View Full Code Here

  public TwigQueryNodeBuilder() {}

  @Override
  public Query build(final QueryNode queryNode)
  throws QueryNodeException {
    final TwigQueryNode tqn = (TwigQueryNode) queryNode;
    final QueryNode root = tqn.getRoot();
    final QueryNode child = tqn.getChild();
    final TwigQuery twigQuery;
    final int rootLevel = tqn.getRootLevel();

    if (root == null && child == null) {
      throw new QueryNodeException(new MessageImpl(QueryParserMessages.EMPTY_MESSAGE));
    }
    if (tqn.getChildren().size() != 2) {
      throw new IllegalArgumentException("A TwigQueryNode cannot have more " +
          "than 2 children:\n" + tqn.getChildren().toString());
    }
    if (child instanceof WildcardNodeQueryNode &&
        root instanceof WildcardNodeQueryNode) {
      throw new QueryNodeException(new MessageImpl("Twig with both root and " +
          "child empty is not allowed."));
View Full Code Here

TOP

Related Classes of org.sindice.siren.qparser.keyword.nodes.TwigQueryNode

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.