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

Examples of org.apache.clerezza.rdf.core.sparql.ResultSet


        try {

            SelectQuery query = (SelectQuery) QueryParser.getInstance().parse(sparql);

            ResultSet resultSet = tcManager.executeSparqlQuery(query, unionMGraph);

            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                UriRef recipeID = (UriRef) solutionMapping.get("recipe");
                UriRef ruleID = (UriRef) solutionMapping.get("rule");
                Literal description = (Literal) solutionMapping.get("description");

                try {
View Full Code Here


        List<Triple> willBeRemoved = new ArrayList<Triple>();
        Lock l = enhancementGraph.getLock().writeLock();
        l.lock();
        try {
            ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, enhancementGraph);
            while (resultSet.hasNext()) {
                SolutionMapping mapping = resultSet.next();
                UriRef ref = (UriRef) mapping.get("enhID");
                Iterator<Triple> tripleItr = enhancementGraph.filter(ref, null, null);
                while (tripleItr.hasNext()) {
                    Triple triple = tripleItr.next();
                    willBeRemoved.add(triple);
View Full Code Here

            log.error("Cannot parse the query generated by QueryGenerator: {}",
                QueryGenerator.getFieldQuery(fieldName), e);
            return;
        }

        ResultSet result = tcManager.executeSparqlQuery(query, ci.getMetadata());
        List<String> values = new ArrayList<String>();
        while (result.hasNext()) {
            SolutionMapping sol = result.next();
            Resource res = sol.get(fieldName.toString());
            if (res == null) continue;
            String value = res.toString();
            if (res instanceof Literal) {
                value = ((Literal) res).getLexicalForm();
View Full Code Here

            String msg = "Cannot parse the SPARQL while trying to retrieve the enhancements of the ContentItem";
            log.error(msg, e);
            throw new StoreException(msg, e);
        }

        ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, this.getEnhancementGraph());
        MGraph metadata = new IndexedMGraph();
        while (resultSet.hasNext()) {
            SolutionMapping mapping = resultSet.next();
            UriRef ref = (UriRef) mapping.get("enhID");
            Iterator<Triple> tripleItr = this.getEnhancementGraph().filter(ref, null, null);
            while (tripleItr.hasNext()) {
                Triple triple = tripleItr.next();
                metadata.add(triple);
View Full Code Here

    public QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
        if(parsedQuery == null){
            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
        }
        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
        final ResultSet result = executeSparqlFieldQuery(query);
        //A little bit complex construct ...
        // first we use the adaptingIterator to convert reseource to string
        // to get the resources we have to retrieve the root-variable of the
        // Iterator<SolutionMapping> provided by the ResultSet of the SPARQL query
        Iterator<String> representationIdIterator = new AdaptingIterator<Resource, String>(
                new Iterator<Resource>() {
                    @Override public void remove() { result.remove(); }
                    @Override public Resource next() {
                        return result.next().get(query.getRootVariableName()); }
                    @Override public boolean hasNext() { return result.hasNext(); }
                },
                new Resource2StringAdapter<Resource>(), String.class);
        return new QueryResultListImpl<String>(query,representationIdIterator,String.class);
    }
View Full Code Here

    public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
        if(parsedQuery == null){
            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
        }
        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
        final ResultSet result = executeSparqlFieldQuery(query);
        //Note: An other possibility would be to first iterate over all results and add it to
        //      a list and create this Iterator than based on the List. This would
        //      be the preferenced way if changes in the graph could affect the
        //     Iteration over the SPARQL query results.
        Iterator<Representation> representationIterator = new AdaptingIterator<SolutionMapping, Representation>(
View Full Code Here

    data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
        DC.title, new PlainLiteralImpl(titleValue)));
    String query = "SELECT ?title WHERE" + "{"
        + "    <http://example.org/book/book1> <"
        + DC.title.getUnicodeString() + "> ?title ." + "}";
    ResultSet resultSet = (ResultSet) TcManager.getInstance()
        .executeSparqlQuery(query, data);
    Assert.assertEquals(titleValue, ((Literal) resultSet.next()
        .get("title")).getLexicalForm());

    List<String> columnNames = resultSet.getResultVars();
    Assert.assertEquals(columnNames.size(), 1);
    Assert.assertEquals(columnNames.get(0), "title");
  }
View Full Code Here

    data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
        DC.title, new PlainLiteralImpl(titleValue)));
    String query = "SELECT ?title WHERE" + "{"
        + "    <http://example.org/book/book1> <"
        + DC.title.getUnicodeString() + "> ?title ." + "}";
    ResultSet resultSet = (ResultSet) TcManager.getInstance()
        .executeSparqlQuery(QueryParser.getInstance().parse(query),
            data);
    Assert.assertEquals(titleValue, ((Literal) resultSet.next()
        .get("title")).getLexicalForm());
  }
View Full Code Here

                        ")" +
                        "} ";
        Collection<CalaisEntityOccurrence> result = new ArrayList<CalaisEntityOccurrence>();
        try {
            SelectQuery sQuery = (SelectQuery) QueryParser.getInstance().parse(query);
            ResultSet rs = tcManager.executeSparqlQuery(sQuery, model);
            while (rs.hasNext()) {
                SolutionMapping row = rs.next();
                CalaisEntityOccurrence occ = new CalaisEntityOccurrence();
                Resource disambiguated = row.get("did");
                occ.id = (disambiguated == null ? row.get("id") : disambiguated);
                if (onlyNERMode) {
                    occ.type = row.get("type");
View Full Code Here

                        ")" +
                        "} ";
        Collection<CalaisEntityOccurrence> result = new ArrayList<CalaisEntityOccurrence>();
        try {
            SelectQuery sQuery = (SelectQuery) QueryParser.getInstance().parse(query);
            ResultSet rs = tcManager.executeSparqlQuery(sQuery, model);
            while (rs.hasNext()) {
                SolutionMapping row = rs.next();
                CalaisEntityOccurrence occ = new CalaisEntityOccurrence();
                Resource disambiguated = row.get("did");
                occ.id = (disambiguated == null ? row.get("id") : disambiguated);
                if (onlyNERMode) {
                    occ.type = row.get("type");
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.sparql.ResultSet

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.