Package org.openrdf.query

Examples of org.openrdf.query.BooleanQuery


        assertTrue(connection.size() > 0);

        int count = connection.getStatements(null, null, null, false).asList().size();
        assertTrue(count > 0);

        BooleanQuery sparqlQuery = (BooleanQuery)connection.prepareQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
        assertTrue("SPARQL query evaluation for "+fileName+" failed",sparqlQuery.evaluate());

        connection.close();
        repository.shutDown();
    }
View Full Code Here


        conBerlin.begin();
        Assert.assertTrue(conBerlin.size() > 0);

        // run a SPARQL test to see if the returned data is correct
        InputStream sparql = this.getClass().getResourceAsStream("dbpedia-berlin.sparql");
        BooleanQuery testLabel = conBerlin.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
        Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());

        conBerlin.commit();
        conBerlin.close();

        ldclient.shutdown();
View Full Code Here

        // test snapshot connection for date2 (i.e. after base import and before updates)
        RepositoryConnection snapshot1 = repository.getSnapshot(date2);

        // query all triples for http://marmotta.incubator.apache.org/testing/ns1/R1, should be exactly 3
        BooleanQuery query1_1 = snapshot1.prepareBooleanQuery(QueryLanguage.SPARQL, "ASK { <http://marmotta.incubator.apache.org/testing/ns1/R1> ?p ?o }");
        Assert.assertTrue("SPARQL query for R1 did not return true", query1_1.evaluate());

        // query all triples for http://marmotta.incubator.apache.org/testing/ns1/R2, should be zero
        BooleanQuery query1_2 = snapshot1.prepareBooleanQuery(QueryLanguage.SPARQL, "ASK { <http://marmotta.incubator.apache.org/testing/ns1/R2> ?p ?o }");
        Assert.assertFalse("SPARQL query for R2 did not return false", query1_2.evaluate());

        snapshot1.commit();
        snapshot1.close();

        // test snapshot connection for date3 (i.e. after first update)
        RepositoryConnection snapshot2 = repository.getSnapshot(date3);

        // query all triples for http://marmotta.incubator.apache.org/testing/ns1/R1, should be exactly 3
        BooleanQuery query2_1 = snapshot2.prepareBooleanQuery(QueryLanguage.SPARQL, "ASK { <http://marmotta.incubator.apache.org/testing/ns1/R1> ?p ?o }");
        Assert.assertTrue("SPARQL query for R1 did not return true", query2_1.evaluate());

        // query all triples for http://marmotta.incubator.apache.org/testing/ns1/R2, should be 3
        BooleanQuery query2_2 = snapshot2.prepareBooleanQuery(QueryLanguage.SPARQL, "ASK { <http://marmotta.incubator.apache.org/testing/ns1/R2> ?p ?o }");
        Assert.assertTrue("SPARQL query for R2 did not return true", query2_2.evaluate());

        snapshot2.commit();
        snapshot2.close();

View Full Code Here

        boolean result = false;
        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                BooleanQuery ask = connection.prepareBooleanQuery(queryLanguage, query);
                result = ask.evaluate();
                connection.commit();
            } catch (MalformedQueryException e) {
                throw new MarmottaException("malformed query, update failed",e);
            } catch (QueryEvaluationException e) {
                throw new MarmottaException("error evaluating querry",e);
View Full Code Here

      }
    }
  }

  private static boolean doBooleanQuery(RepositoryConnection con, String query) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    BooleanQuery resultsTable = con.prepareBooleanQuery(QueryLanguage.SPARQL, query);
    return resultsTable.evaluate();
//
//    Vector<Value[]> results = new Vector<Value[]>();
//    for (int row = 0; bindings.hasNext(); row++) {
//      // System.out.println("RESULT " + (row + 1) + ": ");
//      BindingSet pairs = bindings.next();
View Full Code Here

      }
    }
  }

  private static boolean doBooleanQuery(RepositoryConnection con, String query) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    BooleanQuery resultsTable = con.prepareBooleanQuery(QueryLanguage.SPARQL, query);
    return resultsTable.ask();
 
View Full Code Here

  public BooleanQuery prepareBooleanQuery(QueryLanguage language, final String query, String baseURI) throws RepositoryException, MalformedQueryException {

    if (language != QueryLanguage.SPARQL)
      throw new UnsupportedQueryLanguageException(" : Only SPARQL queries are supported");

    BooleanQuery q = new VirtuosoBooleanQuery() {
      public boolean evaluate() throws QueryEvaluationException {
        return executeSPARQLForBooleanResult(query, getDataset(), getIncludeInferred(), getBindings());
      }
    };
    return q;
View Full Code Here

   */
//??TODO use another new options timeout
  public BooleanQuery prepareBooleanQuery(QueryLanguage language, final String query, String baseURI)
    throws StoreException, MalformedQueryException
  {
    BooleanQuery q = new VirtuosoBooleanQuery() {
      public boolean ask() throws StoreException {
        return executeSPARQLForBooleanResult(query, getDataset(), getIncludeInferred(), getBindings());
      }
    };
    return q;
View Full Code Here

            conn.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
            conn.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_LANGUAGE_TAGS);
            conn.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_RELATIVE_URIS);
            conn.add(openStreamForResource(resultFilePath),
                    inputUri, SesameTestHelper.detectFileFormat(resultFilePath));
            BooleanQuery query = repository.getConnection().prepareBooleanQuery(QueryLanguage.SPARQL, queryStr, inputUri);
            boolean result = query.evaluate();

            if (result != expectedResult) {
                System.err.println("Test failed for: " + inputUri);
                System.err.println("Expected [" + expectedResult + "] but found [" + result + "]");
                System.err.println("Query: " + queryStr);
View Full Code Here

TOP

Related Classes of org.openrdf.query.BooleanQuery

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.