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

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


        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


        + "?x " + FOAF.mbox + " ?email . "
        + "?x " + PLATFORM.userName + " \"" + user + "\" . "
        + "}";
    try {
      SelectQuery selectQuery = (SelectQuery) QueryParser.getInstance().parse(queryString);
      ResultSet result = tcManager.executeSparqlQuery(selectQuery, systemGraph);
      if (result.hasNext()) {
        Resource email = result.next().get("email");
        String emailString = ((UriRef) email).getUnicodeString();
        //TODO should add personal name (if available) as well
        return new InternetAddress(emailString.substring("mailto:".length()));
      }
    } catch (ParseException ex) {
View Full Code Here

            log.error(msg, e);
            throw new StoreException(msg, e);
        }

        List<Triple> willBeRemoved = new ArrayList<Triple>();
        ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, enhancementGraph);
        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();
                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

        Query sparql;
        try {
            sparql = QueryParser.getInstance().parse(query);

            ResultSet resultSet = tcManager.executeSparqlQuery((SelectQuery) sparql, recipeGraph);

            StringBuilder stanbolRulesBuilder = new StringBuilder();

            boolean firstIteration = true;
            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                Resource nameResource = solutionMapping.get("ruleName");
                Resource bodyResource = solutionMapping.get("ruleBody");
                Resource headResource = solutionMapping.get("ruleHead");

                StringBuilder stanbolRuleBuilder = new StringBuilder();
View Full Code Here

        try {

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

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

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

                try {
                    Recipe recipe = getRecipe(recipeID);
View Full Code Here

        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

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.