Package org.openrdf.query

Examples of org.openrdf.query.TupleQuery


    boolean answer = false;
    try {
      RepositoryConnection conn = m_source.getConnection();
      String query = "SELECT * FROM {<" + ((URI) subject).toString() + ">} <"
              + property.toString() + "> {y}";
            TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SERQL, query);
            TupleQueryResult results = q.evaluate();
      answer = results.hasNext();
      results.close();
      conn.close();
    } catch (Exception e) {
      ;
View Full Code Here


    Statement answer = null;
    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();
      if (results.hasNext()) {
        Value object = results.next().getValue("y");
        answer = new StatementImpl(subject, property, object);
      }
      results.close();
View Full Code Here

    Vector<Resource> resources = new Vector<Resource>();
    RepositoryConnection conn;
    try {
      conn = in.getConnection();

      TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, this._SPARQL);
      TupleQueryResult result = tupleQuery.evaluate();

      String firstBindingName = result.getBindingNames().get(0);

      while (result.hasNext()) {
        Value uri = result.next().getBinding(firstBindingName).getValue();
View Full Code Here

    Vector<Value> values = new Vector<Value>();
    RepositoryConnection conn;
    try {
      conn = in.getConnection();

      TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, this._SPARQL);
      TupleQueryResult result = tupleQuery.evaluate();

      String firstBindingName = result.getBindingNames().get(0);

      while (result.hasNext()) {
        Value uri = result.next().getBinding(firstBindingName).getValue();
View Full Code Here

  protected void getTerms(Repository repos, String name, String uri, List<RDFSClass> classes, List<RDFSProperty> properties) throws VocabularyImportException {
    try {
      RepositoryConnection con = repos.getConnection();
      try {

        TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL,CLASSES_QUERY_P1 + uri + CLASSES_QUERY_P2);
        TupleQueryResult res = query.evaluate();

        Set<String> seen = new HashSet<String>();
        while (res.hasNext()) {
          BindingSet solution = res.next();
          String clazzURI = solution.getValue("resource").stringValue();
          if (seen.contains(clazzURI)) {
            continue;
          }
          seen.add(clazzURI);
          String label = getFirstNotNull(new Value[] {
              solution.getValue("en_label"),
              solution.getValue("label") });
          String description = getFirstNotNull(new Value[] {
              solution.getValue("en_definition"),
              solution.getValue("definition"),
              solution.getValue("en_description"),
              solution.getValue("description") });
          RDFSClass clazz = new RDFSClass(clazzURI, label,
              description, name, uri);
          classes.add(clazz);
        }
       
        query = con.prepareTupleQuery(QueryLanguage.SPARQL,PROPERTIES_QUERY_P1 + uri + PROPERTIES_QUERY_P2);
        res = query.evaluate();
        seen = new HashSet<String>();
        while (res.hasNext()) {
          BindingSet solution = res.next();
          String propertyUri = solution.getValue("resource").stringValue();
          if (seen.contains(propertyUri)) {
View Full Code Here

        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                TupleQuery tupleQuery = connection.prepareTupleQuery(queryLanguage, query);
                TupleQueryResult r = tupleQuery.evaluate();
                try {
                    while (r.hasNext()) {
                        BindingSet s = r.next();
                        Map<String, Value> map = new HashMap<String, Value>();
                        for (Binding binding : s) {
View Full Code Here

        RepositoryConnection con1 = repository.getConnection();
        RepositoryConnection con2 = reference.getConnection();
        try {
            con1.begin();

            TupleQuery query1 = con1.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
            TupleQueryResult result1 = query1.evaluate();

            con1.commit();

            Assert.assertTrue(result1.hasNext());


            con2.begin();

            TupleQuery query2 = con2.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
            TupleQueryResult result2 = query2.evaluate();

            con2.commit();

            compareResults(result1,result2);
View Full Code Here

        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                TupleQuery tupleQuery = connection.prepareTupleQuery(queryLanguage, query);
                TupleQueryResult r = tupleQuery.evaluate();
                try {
                    while (r.hasNext()) {
                        BindingSet s = r.next();
                        Map<String, Value> map = new HashMap<String, Value>();
                        for (Binding binding : s) {
View Full Code Here

            Assert.assertTrue(con.hasStatement(subject,predicate1, object11));
            Assert.assertFalse(con.hasStatement(subject, predicate2, object21));

            String queryStr = "SELECT ?X ?Z WHERE { ?X ?Y ?Z }";

            TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL, queryStr);
            List<BindingSet> result = Iterations.asList(query.evaluate());
            Assert.assertEquals(2,result.size());
            con.commit();
        } finally {
            con.close();
        }
View Full Code Here

            Assert.assertTrue(con.hasStatement(subject,predicate1, object11));
            Assert.assertFalse(con.hasStatement(subject, predicate2, object21));

            String queryStr = "SELECT ?X ?Z WHERE { ?X ?P ?Y . ?Y ?P ?Z }";

            TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL, queryStr);
            List<BindingSet> result = Iterations.asList(query.evaluate());
            Assert.assertEquals(1,result.size());
            con.commit();
        } finally {
            con.close();
        }
View Full Code Here

TOP

Related Classes of org.openrdf.query.TupleQuery

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.