Package org.openrdf.query

Examples of org.openrdf.query.TupleQueryResult


        + "        mf:action {query}; " + "        mf:result {result} " + "USING NAMESPACE "
        + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  mfx = <http://www.openrdf.org/test-manifest-extensions#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

    TupleQueryResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (tests.hasNext()) {
      BindingSet testBindings = tests.next();
      String testName = testBindings.getValue("testName").toString();
      String queryFile = testBindings.getValue("query").toString();
      Value result = testBindings.getValue("result");
      if (MFX_CORRECT.equals(result)) {
        positiveTests.addTest(new SeRQLParserTest(testName, queryFile, result));
      }
      else if (MFX_PARSE_ERROR.equals(result)) {
        negativeTests.addTest(new SeRQLParserTest(testName, queryFile, result));
      }
      else {
        logger.warn("Unexpected result value for test \"" + testName + "\": " + result);
      }
    }

    tests.close();
    con.close();
    manifestRep.shutDown();

    suite.addTest(positiveTests);
    suite.addTest(negativeTests);
View Full Code Here


    String query = "SELECT DISTINCT manifestFile " + "FROM {x} rdf:first {manifestFile} "
        + "USING NAMESPACE " + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

    TupleQueryResult manifestResults = con.prepareTupleQuery(QueryLanguage.SERQL, query, MANIFEST_FILE).evaluate();

    while (manifestResults.hasNext()) {
      BindingSet bindingSet = manifestResults.next();
      String manifestFile = bindingSet.getValue("manifestFile").toString();
      suite.addTest(SPARQLQueryTest.suite(manifestFile, factory));
    }

    manifestResults.close();
    con.close();
    manifestRep.shutDown();

    logger.info("Created aggregated test suite with " + suite.countTestCases() + " test cases.");
    return suite;
View Full Code Here

    con.add(manifest, MANIFEST_FILE, rdfFormat);

    logger.info("Searching for sub-manifests");
    List<String> subManifestList = new ArrayList<String>();

    TupleQueryResult subManifests = con.prepareTupleQuery(QueryLanguage.SERQL, SUBMANIFEST_QUERY).evaluate();
    while (subManifests.hasNext()) {
      BindingSet bindings = subManifests.next();
      subManifestList.add(bindings.getValue("subManifest").toString());
    }
    subManifests.close();

    logger.info("Found {} sub-manifests", subManifestList.size());

    for (String subManifest : subManifestList) {
      logger.info("Loading sub manifest {}", subManifest);
      con.clear();

      URL subManifestURL = new URL(subManifest);
      rdfFormat = RDFFormat.forFileName(subManifest, RDFFormat.TURTLE);
      con.add(subManifestURL, subManifest, rdfFormat);

      TestSuite subSuite = new TestSuite(subManifest.substring(HOST.length()));

      logger.info("Creating test cases for {}", subManifest);
      TupleQueryResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, TESTCASE_QUERY).evaluate();
      while (tests.hasNext()) {
        BindingSet bindingSet = tests.next();

        String testURI = bindingSet.getValue("TestURI").toString();
        String testName = bindingSet.getValue("Name").toString();
        String testAction = bindingSet.getValue("Action").toString();
        boolean positiveTest = bindingSet.getValue("Type").toString().equals(
            "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#PositiveSyntaxTest");

        subSuite.addTest(new SPARQLSyntaxTest(testURI, testName, testAction, positiveTest));
      }
      tests.close();

      suite.addTest(subSuite);
    }

    con.close();
View Full Code Here

    boolean isWritable = false;
    String repositoryURL = httpClient.getRepositoryURL();

    try {
      TupleQueryResult repositoryList = httpClient.getRepositoryList();
      try {
        while (repositoryList.hasNext()) {
          BindingSet bindingSet = repositoryList.next();
          Value uri = bindingSet.getValue("uri");

          if (uri != null && uri.stringValue().equals(repositoryURL)) {
            isWritable = LiteralUtil.getBooleanValue(bindingSet.getValue("writable"), false);
            break;
          }
        }
      }
      catch (QueryEvaluationException e) {
        throw new RepositoryException(e);
      }
      finally {
        try {
          repositoryList.close();
        }
        catch (QueryEvaluationException e) {
          throw new RepositoryException(e);
        }
      }
View Full Code Here

  // implements edu.lehigh.swat.bench.ubt.api.Repository.issueQuery(...)
  public QueryResult issueQuery(Query query) {

    try {
      RepositoryConnection con = repository.getConnection();
      TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query.getString()).evaluate();
      con.close();

      return new LUBMQueryResult(queryResult);
    }
    catch (MalformedQueryException e) {
View Full Code Here

    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT DISTINCT x FROM {x} rdf:type {y} WHERE isResource(y) AND " +
          "y = <" + OWL.OBJECTPROPERTY + ">";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
            while (results.hasNext()) {
                BindingSet s = results.next();
        Value result = s.getValue("x");
        classes.add(result);
      }
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
    }
    return classes.iterator();
View Full Code Here

    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT DISTINCT x FROM {x} rdf:type {y} WHERE isResource(y) AND " +
          "y = <" + OWL.DATATYPEPROPERTY + ">";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
            while (results.hasNext()) {
                BindingSet s = results.next();
        Value result = s.getValue("x");
        classes.add(result);
      }
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
    }
    return classes.iterator();   
View Full Code Here

    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT DISTINCT x FROM {x} rdf:type {y} WHERE isResource(y) AND " +
          "y = <" + OWL.ANNOTATIONPROPERTY + ">";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
            while (results.hasNext()) {
                BindingSet s = results.next();
        Value result = s.getValue("x");
        classes.add(result);
      }
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
    }
    return classes.iterator();
View Full Code Here

    Vector<Value> classes = new Vector<Value>();
    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT DISTINCT x FROM {x} p {y}";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
            while (results.hasNext()) {
                BindingSet s = results.next();
        Value result = s.getValue("x");
        classes.add(result);
      }
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
    }
    return classes.iterator();
View Full Code Here

    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT y FROM {<" + ((URI) subject).toString() + ">} <"
              + property.toString() + "> {y}";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
            while (results.hasNext()) {
                BindingSet s = results.next();
        Value result = s.getValue("x");
        objects.add(result);
      }
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
    }
    return objects.iterator();
View Full Code Here

TOP

Related Classes of org.openrdf.query.TupleQueryResult

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.