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

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


                .append(prefixUri).append("> SELECT $").append(variable)
                .append(" WHERE { <").append(subject).append("> ")
                .append(prefix).append(":").append(predicate).append(" ?")
                .append(variable).append(" }");

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
        SelectQuery selectQuery = (SelectQuery) q;
        Assert.assertTrue(selectQuery.getSelection().get(0)
                .equals(new Variable(variable)));

        GraphPattern gp = (GraphPattern) selectQuery.getQueryPattern()
View Full Code Here


                .append(" ?").append(variable2).append(" . OPTIONAL { ?")
                .append(variable1).append(" ").append(prefix2).append(":")
                .append(predicate2).append(" ?").append(variable3)
                .append(" .} FILTER ( ! bound(?").append(variable3).append(") ) }");

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
        SelectQuery selectQuery = (SelectQuery) q;
        Assert.assertTrue(selectQuery.getSelection().size() == 2);
        Set<Variable> vars = new HashSet<Variable>(2);
        Variable var1 = new Variable(variable1);
        Variable var2 = new Variable(variable2);
View Full Code Here

    public Object sparql(@QueryParam(value = "query") String sparqlQuery) throws SparqlQueryEngineException,
                                                                         ParseException {
        if (sparqlQuery == null) {
            return Response.ok(new Viewable("sparql", this), TEXT_HTML).build();
        }
        Query query = QueryParser.getInstance().parse(sparqlQuery);
        String mediaType = "application/sparql-results+xml";
        if (query instanceof DescribeQuery || query instanceof ConstructQuery) {
            mediaType = "application/rdf+xml";
        }
        Object result = tcManager.executeSparqlQuery(query, getEnhancerConfigGraph());
View Full Code Here

    public Response sparql(@QueryParam(value = "query") String sparqlQuery, @Context HttpHeaders headers) throws SparqlQueryEngineException,
                                                                                                         ParseException {
        if (sparqlQuery == null) {
            return Response.ok(new Viewable("index", this), TEXT_HTML).build();
        }
        Query query = QueryParser.getInstance().parse(sparqlQuery);
        String mediaType = "application/sparql-results+xml";
        if (query instanceof DescribeQuery || query instanceof ConstructQuery) {
            mediaType = "application/rdf+xml";
        }
        // TODO: remove dependency on the "store" service and make it possible to select the default graph
View Full Code Here

                    || defaultGraphUri.getUnicodeString().equals("")) {
                defaultGraph = contentGraph;
            } else {
                defaultGraph = tcManager.getTriples(defaultGraphUri);
            }
            Query query = QueryParser.getInstance().parse(queryString);
            result = tcManager.executeSparqlQuery(query, defaultGraph);
            if (result instanceof Graph) {
                return (Graph) result;
            } else if ((result instanceof ResultSet)
                    || (result instanceof Boolean)) {
View Full Code Here

                + "} FILTER ((?property) != (<http://www.w3.org/2002/07/owl#bottomObjectProperty>))\n"
                + "FILTER ((?range) != (<http://www.w3.org/2002/07/owl#Nothing>))\n"
                + "FILTER (! (BOUND(?somesub)))\n"
                + "} \n";

        Query query = QueryParser.getInstance().parse(queryString);
        Assert.assertEquals(queryString.replaceAll("\\s", "").trim(), query.toString().replaceAll("\\s", "").trim());
    }
View Full Code Here

                + "        OPTIONAL { ?subproperty dc:description ?subproperty_description . }\n"
                + "    }\n"
                + "    OPTIONAL { ?property dc:description ?property_description . }\n"
                + "} ";

        Query query1 = QueryParser.getInstance().parse(queryString);
        Thread.sleep(5000l);
        Query query2 = QueryParser.getInstance().parse(queryString);
        Assert.assertEquals(query1.toString(), query2.toString());
    }
View Full Code Here

TOP

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

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.