Package org.apache.clerezza.rdf.core.sparql.query

Examples of org.apache.clerezza.rdf.core.sparql.query.Variable


      put(new Variable(varName), toResource(querySolution.get(varName)));
    }
  }
  @Override
  public Resource get(String name) {
    return get(new Variable(name));
  }
View Full Code Here


    final String queryString = "SELECT ?title FROM <http://example.org/library>" +
        " WHERE { <http://example.org/book/book1>" +
        " <http://purl.org/dc/elements/1.1/title> ?title . }";

    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    Variable variable = new Variable("title");
    selectQuery.addSelection(variable);
    UriRef defaultGraph = new UriRef("http://example.org/library");
    selectQuery.addDefaultGraph(defaultGraph);
    ResourceOrVariable subject = new ResourceOrVariable(
        new UriRef("http://example.org/book/book1"));
View Full Code Here

    ResourceOrVariable s = new ResourceOrVariable(
        new UriRef("http://example.org/person#Alice"));
    UriRefOrVariable p = new UriRefOrVariable(
        new UriRef("http://www.w3.org/2001/vcard-rdf/3.0#FN"));
    ResourceOrVariable o = new ResourceOrVariable(new Variable("name"));
    Set<TriplePattern> constructTriplePatterns = new HashSet<TriplePattern>();
    constructTriplePatterns.add(new SimpleTriplePattern(s, p, o));
    SimpleConstructQuery constructQuery = new SimpleConstructQuery(constructTriplePatterns);

    s = new ResourceOrVariable(new Variable("x"));
    p = new UriRefOrVariable(new UriRef("http://xmlns.com/foaf/0.1/name"));
    Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
    triplePatterns.add(new SimpleTriplePattern(s, p, o));

    SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
View Full Code Here

  public void testAskQuery() {

    final String queryString = "ASK WHERE { ?x <http://xmlns.com/foaf/0.1/name> " +
        "\"Alice\"^^<http://www.w3.org/2001/XMLSchema#string> . }";

    ResourceOrVariable s = new ResourceOrVariable(new Variable("x"));
    UriRefOrVariable p = new UriRefOrVariable(
        new UriRef("http://xmlns.com/foaf/0.1/name"));
    ResourceOrVariable o = new ResourceOrVariable(
        LiteralFactory.getInstance().createTypedLiteral("Alice"));
View Full Code Here

        "?x <http://purl.org/dc/elements/1.1/title> ?title . " +
        "?x <http://example.org/ns#price> ?price . " +
        "FILTER ((?price) < (\"30.5\"^^<http://www.w3.org/2001/XMLSchema#double>)) " +
        "}";

    Variable price = new Variable("price");
    Variable title = new Variable("title");
    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    selectQuery.addSelection(title);
    selectQuery.addSelection(price);

    Variable x = new Variable("x");
    Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
    triplePatterns.add(new SimpleTriplePattern(x,
        new UriRef("http://example.org/ns#price"), price));
    triplePatterns.add(new SimpleTriplePattern(x,
        new UriRef("http://purl.org/dc/elements/1.1/title"), title));
View Full Code Here

    final String queryString = "SELECT ?resource WHERE { " +
        "?resource <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?myType . " +
        "FILTER ((?resource) = (<http://example.org/ontology#special>)) " +
        "}";

    Variable resource = new Variable("resource");
    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    selectQuery.addSelection(resource);

    Variable myType = new Variable("myType");
    Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
    triplePatterns.add(new SimpleTriplePattern(resource,
        new UriRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), myType));

    SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
View Full Code Here

  @Test
  public void testOrderBy() {

    final String queryString = "SELECT * WHERE { ?a ?b ?c . } ORDER BY DESC(?c)";

    Variable a = new Variable("a");
    Variable b = new Variable("b");
    Variable c = new Variable("c");
    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    selectQuery.setSelectAll();
    selectQuery.addSelection(a);
    selectQuery.addSelection(b);
    selectQuery.addSelection(c);
View Full Code Here

    final String queryString = "SELECT ?title ?price WHERE { " +
        "?x <http://purl.org/dc/elements/1.1/title> ?title . " +
        "OPTIONAL { ?x <http://example.org/ns#price> ?price . } " +
        "}";

    Variable title = new Variable("title");
    Variable price = new Variable("price");
    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    selectQuery.addSelection(title);
    selectQuery.addSelection(price);

    Variable x = new Variable("x");
    Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
    triplePatterns.add(new SimpleTriplePattern(x,
        new UriRef("http://purl.org/dc/elements/1.1/title"), title));

    SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
View Full Code Here

    final String queryString = "SELECT ?p WHERE { " +
        "<http://localhost/testitem> ?p ?x . " +
        "FILTER REGEX(?x,\".*uni.*\"^^<http://www.w3.org/2001/XMLSchema#string>) }";

    Variable p = new Variable("p");
    SimpleSelectQuery selectQuery = new SimpleSelectQuery();
    selectQuery.addSelection(p);

    Variable x = new Variable("x");
    Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
    triplePatterns.add(new SimpleTriplePattern(
        new UriRef("http://localhost/testitem"), p, x));

    SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
View Full Code Here

                                         UnsupportedTypeForExportException {

        org.apache.stanbol.rules.manager.atoms.NumericVariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.NumericVariableAtom) ruleAtom;

        String variableName = tmp.getVariableName();
        Variable variable = new Variable(variableName);

        return (T) new ClerezzaSparqlObject(variable);
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.sparql.query.Variable

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.