Examples of TupleQuery


Examples of org.openrdf.query.TupleQuery

    testCon.add(alice, name, nameAlice);
    testCon.add(alice, mbox, mboxAlice);
    testCon.add(bob, name, nameBob);
    testCon.add(bob, mbox, mboxBob);

    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SERQL, "SELECT o FROM {} P {o}");
    int total = query.evaluate().asList().size();
    query.setOffset(1);
    assertEquals(total - 1, query.evaluate().asList().size());
  }
View Full Code Here

Examples of org.openrdf.query.TupleQuery

    testCon.add(alice, name, nameAlice);
    testCon.add(alice, mbox, mboxAlice);
    testCon.add(bob, name, nameBob);
    testCon.add(bob, mbox, mboxBob);

    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SERQL, "SELECT o FROM {} P {o}");
    query.setLimit(1);
    assertEquals(1, query.evaluate().asList().size());
  }
View Full Code Here

Examples of org.openrdf.query.TupleQuery

  {
    BNode node = testCon2.getValueFactory().createBNode();
    testCon2.add(node, name, nameAlice);

    // select an arbitrary blank node
    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SPARQL,
        "select ?s where {?s ?p ?o FILTER (isBlank(?s))}");

    BNode blankNode = null;

    TupleResult result = query.evaluate();
    while (result.hasNext()) {
      BindingSet set = result.next();
      blankNode = (BNode)set.getValue("s");
    }
    result.close();

    if (blankNode != null) {
      query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, "select ?s where {?s ?p ?o}");
      query.setBinding("s", blankNode);

      result = query.evaluate();
      try {
        // the query must have at least one result
        assertTrue(result.hasNext());
      }
      finally {
View Full Code Here

Examples of org.openrdf.query.TupleQuery

    }
    finally {
      stIter.close();
    }

    TupleQuery tupleQuery = testCon.prepareTupleQuery(QueryLanguage.SERQL,
        "SELECT S, P, O FROM {S} P {O} WHERE P = <" + pred.stringValue() + ">", null);

    TupleResult iter;
    iter = tupleQuery.evaluate();

    try {
      assertTrue(iter.hasNext());
      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
      assertEquals(pred, bindings.getValue("P"));
      assertEquals(obj, bindings.getValue("O"));
      assertFalse(iter.hasNext());
    }
    finally {
      iter.close();
    }

    tupleQuery = testCon.prepareTupleQuery(QueryLanguage.SERQL, "SELECT S, P, O FROM {S} P {O} WHERE P = <"
        + pred.stringValue() + ">", null);
    tupleQuery.setBinding("S", subj);
    tupleQuery.setBinding("P", pred);
    tupleQuery.setBinding("O", obj);

    iter = tupleQuery.evaluate();

    try {
      assertTrue(iter.hasNext());
      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
View Full Code Here

Examples of org.openrdf.query.TupleQuery

    if (dataset != null) {
      query.setDataset(dataset);
    }

    if (query instanceof TupleQuery) {
      TupleQuery tupleQuery = (TupleQuery)query;

      int offset = ServerUtil.parseIntegerParam(params, Protocol.OFFSET, tupleQuery.getOffset());
      int limit = ServerUtil.parseIntegerParam(params, Protocol.LIMIT, tupleQuery.getLimit());
      tupleQuery.setOffset(offset);
      tupleQuery.setLimit(limit);
    }

    setBindings(query, params, vf);
  }
View Full Code Here

Examples of org.openrdf.query.TupleQuery

         RepositoryConnection con = _repository.getConnection();
         try
         {
           BindingSet bindingSet;

           TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, String.format(SELECT_CodeList_TEMPLATE,codeList));
           TupleQueryResult result = tupleQuery.evaluate();
              
           if(result.hasNext())
             {                
               bindingSet = result.next();
               codeListURI = bindingSet.getValue("sub").toString();
View Full Code Here

Examples of org.openrdf.query.TupleQuery

             
            }
          }else{
            //return values without metadata
            RepositoryConnection connection = dataRepo.getConnection();
            TupleQuery compiledQuery = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);
            TupleQueryResult results = compiledQuery.evaluate()
           
         
            BindingSet set;
            Resource r;
            String variable = results.getBindingNames().get(0);
View Full Code Here

Examples of org.openrdf.query.TupleQuery

      if (con!=null) {
        try {
         
          String query = "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT DISTINCT * WHERE {<"+r+"> rdf:type ?o }";
 
          TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query);
 
          TupleQueryResult result = tupleQuery.evaluate();
          try {
            String firstBindingName = result.getBindingNames().get(0);
            while (result.hasNext()) {
              Value uri = result.next().getBinding(firstBindingName).getValue();
              if (uri instanceof URI) {
View Full Code Here

Examples of org.openrdf.query.TupleQuery

      }
      if (con!=null) {
        try {
          String query = "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT DISTINCT ?o WHERE { ?s rdf:type ?o } ORDER BY ?o";
 
          TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query);
 
          TupleQueryResult result = tupleQuery.evaluate();
          try {
            String firstBindingName = result.getBindingNames().get(0);
            while (result.hasNext()) {
              Value uri = result.next().getBinding(firstBindingName).getValue();
              if ((uri instanceof URI) &&
View Full Code Here

Examples of org.openrdf.query.TupleQuery

    }
    try {

      String query = "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?s WHERE { ?s rdf:type <" + uri + "> }";

      TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query);
      TupleQueryResult result = tupleQuery.evaluate();

      try {

        String firstBindingName = result.getBindingNames().get(0);
        while (result.hasNext()) {
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.