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

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


      doc.appendChild(root);
      Element head = doc.createElement("head");
      root.appendChild(head);
      Set<Object> variables = new HashSet<Object>();
      Element results = doc.createElement("results");
      SolutionMapping solutionMapping = null;
      while (queryResult.hasNext()) {
        solutionMapping = queryResult.next();       
        createResultElement(solutionMapping, results, doc);       
      }
      createVariable(solutionMapping, head, doc);
View Full Code Here


   *
   */
  private Element createResultsElement(ResultSet resultSet, Document doc) {
    Element results = doc.createElement("results");
    while (resultSet.hasNext()) {
      SolutionMapping solutionMap = resultSet.next();
      Set<Variable> keys = solutionMap.keySet();
      Element result = doc.createElement("result");
      results.appendChild(result);

      for (Variable key : keys) {
        Element bindingElement = doc.createElement("binding");
        bindingElement.setAttribute("name", key.getName());
        bindingElement.appendChild(createValueElement(
            (Resource) solutionMap.get(key), doc));
        result.appendChild(bindingElement);
      }
    }
    return results;
  }
View Full Code Here

        }

        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

        }

        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

        }

        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

            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();
                stanbolRuleBuilder.append(((Literal) nameResource).getLexicalForm());
                stanbolRuleBuilder.append("[");
                stanbolRuleBuilder.append(((Literal) bodyResource).getLexicalForm());
View Full Code Here

            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);

                    log.info("Found recipe {}.", recipeID.toString());
View Full Code Here

            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 {
                    Recipe recipe = getRecipe(recipeID);
                    Rule rule = new RecipeRule(recipe, getRule(recipe, ruleID));
                    if (description != null) {
View Full Code Here

            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 {
                    Recipe recipe = getRecipe(recipeID);
                    Rule rule = new RecipeRule(recipe, getRule(recipe, ruleID));
                    if (description != null) {
View Full Code Here

        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

TOP

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

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.