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

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


        if (sparqlQuery == null) {
            populateTripleCollectionList(getServices(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";
        }
View Full Code Here


    public Object sparql(@QueryParam(value = "query") String sparqlQuery,
                         @Context HttpHeaders headers) throws 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";
        }
        ResponseBuilder responseBuilder;
View Full Code Here

        Set<UriRef> referredGraphs;
        JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString));
        SparqlUnit sparqlUnit;
        sparqlUnit = parser.parse();
        if (sparqlUnit.isQuery()) {
            Query q = sparqlUnit.getQuery();
            DataSet dataSet = q.getDataSet();
            if (dataSet != null) {
                referredGraphs = dataSet.getDefaultGraphs();
                referredGraphs.addAll(dataSet.getNamedGraphs());
            } else {
                referredGraphs = new HashSet<UriRef>();
View Full Code Here

        if(parsedQuery == null){
            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
        }
        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
        int limit = QueryUtils.getLimit(query, getConfig().getDefaultQueryResultNumber(), getConfig().getMaxQueryResultNumber());
        Query sparqlQuery;
        //NOTE:
        // - use the endpoint type standard, because we do not know what type of
        //   SPARQL implementation is configured for Clerezza via OSGI
        String sparqlQueryString = SparqlQueryUtils.createSparqlConstructQuery(
            query, limit,EndpointTypeEnum.Standard);
View Full Code Here

    public Object sparql(@QueryParam(value = "query") String sparqlQuery,
                         @Context HttpHeaders headers) throws 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";
        }
        ResponseBuilder responseBuilder;
View Full Code Here

        queryStrBuf.append("SELECT ?").append(variable)
                .append(" FROM <").append(defaultGraph)
                .append("> WHERE { <").append(subject).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)));
        Assert.assertTrue(selectQuery.getDataSet().getDefaultGraphs().toArray()[0]
                .equals(new UriRef(defaultGraph)));
View Full Code Here

                new SimpleTriplePattern(s, p, o)));
    }

    @Test(expected=ParseException.class)
    public void testInvalidQuery() throws ParseException {
        Query q = QueryParser.getInstance().parse("Hello");
    }
View Full Code Here

        queryStrBuf.append("CONSTRUCT { <").append(subject1).append("> <")
                .append(predicate1).append("> ?").append(variable1)
                .append("} WHERE { ?").append(variable2).append(" <")
                .append(predicate2).append("> ?").append(variable1).append("}");

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(ConstructQuery.class.isAssignableFrom(q.getClass()));
        ConstructQuery constructQuery = (ConstructQuery) q;
        Set<TriplePattern> triplePatterns = constructQuery
                .getConstructTemplate();
        Assert.assertTrue(triplePatterns.size()==1);
View Full Code Here

        final String resource = "http://example.org/book/book1";

        StringBuffer queryStrBuf = new StringBuffer();
        queryStrBuf.append("DESCRIBE <").append(resource).append(">");

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(DescribeQuery.class.isAssignableFrom(q.getClass()));
        DescribeQuery describeQuery = (DescribeQuery) q;
        Assert.assertTrue(describeQuery.getResourcesToDescribe().get(0)
                .getResource().equals(new UriRef(resource)));
    }
View Full Code Here

        StringBuffer queryStrBuf = new StringBuffer();
        queryStrBuf.append("ASK { ?").append(variable).append(" <")
                .append(predicate).append("> \"").append(object).append("\" }");

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(AskQuery.class.isAssignableFrom(q.getClass()));
        AskQuery askQuery = (AskQuery) q;

        GraphPattern gp = (GraphPattern) askQuery.getQueryPattern()
                .getGraphPatterns().toArray()[0];
        Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
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.