Package org.ontoware.rdf2go.model

Examples of org.ontoware.rdf2go.model.QueryResultTable


   
    // simple SPARQL SELECT
    System.out.println("Query 1:");
    // select every resorce which is tagged with tagJava
    String queryString = "SELECT ?person WHERE { ?person <"+hasTag+"> "+tagJava.toSPARQL()+" }";
    QueryResultTable results = model.sparqlSelect(queryString);
    for(QueryRow row : results) {
      System.out.println(row);
    }
   
    // another SPARQL SELECT
    System.out.println("Query 2:");
    // select resource and tag in every tagging statement
    queryString = "SELECT ?resource ?tag WHERE { ?resource <"+hasTag+"> ?tag }";
    results = model.sparqlSelect(queryString);
    for(String var : results.getVariables()) {
      System.out.println(var);
    }
    for(QueryRow row : results) {
      System.out.println(row.getValue("resource") + " is tagged as " + row.getValue("tag"));
    }
View Full Code Here


          com.hp.hpl.jena.query.Syntax.syntaxARQ);
    }

    QueryExecution exec = QueryExecutionFactory.create(
        this.countStatementsQuery, this.dataset, initialBindings);
    QueryResultTable result = new QueryResultTableImpl(exec);
    return Long
        .parseLong(result.iterator().next().getLiteralValue("count"));
  }
View Full Code Here

  // work around Sesame not having this yet
  /* subclasses should overwrite this method for better performance */
  @Override
    public boolean sparqlAsk(String query) throws ModelRuntimeException,
      MalformedQueryException {
    QueryResultTable table = sparqlSelect(query);
    ClosableIterator<QueryRow> it = table.iterator();
    boolean result = it.hasNext();
    it.close();
    return result;
  }
View Full Code Here

   *
   * ignores context
   */
  @Override
    public Collection<Resource> getAllReificationsOf(Statement statement) {
    QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { \n"
        + " ?res " + RDF.type.toSPARQL() + " "
        + RDF.Statement.toSPARQL() + " ." + " ?res "
        + RDF.subject.toSPARQL() + " "
        + statement.getSubject().toSPARQL() + " ." + " ?res "
        + RDF.predicate.toSPARQL() + " "
        + statement.getPredicate().toSPARQL() + " ." + " ?res "
        + RDF.object.toSPARQL() + " "
        + statement.getObject().toSPARQL() + " ." + " }");
    LinkedList<Resource> result = new LinkedList<Resource>();
    ClosableIterator<QueryRow> it = table.iterator();
    while (it.hasNext()) {
      Resource res = it.next().getValue("res").asResource();
      result.add(res);
    }
    it.close();
View Full Code Here

  }
 
  // work around Sesame not having this yet
  @Override
  public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException {
    QueryResultTable table = sparqlSelect(query);
    ClosableIterator<QueryRow> it = table.iterator();
    boolean result = it.hasNext();
    it.close();
    return result;
  }
View Full Code Here

   * inefficient, loads all in memory. should be OK for almost all practical
   * cases (when each statement has a small number of refications)
   */
  @Override
  public Collection<Resource> getAllReificationsOf(Statement statement) {
    QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { " + " ?res "
            + RDF.type.toSPARQL() + " " + RDF.Statement.toSPARQL() + " ." + " ?res "
            + RDF.subject.toSPARQL() + " " + statement.getSubject().toSPARQL() + " ."
            + " ?res " + RDF.predicate.toSPARQL() + " " + statement.getPredicate().toSPARQL()
            + " ." + " ?res " + RDF.object.toSPARQL() + " " + statement.getObject().toSPARQL()
            + " ." + " }");
    LinkedList<Resource> result = new LinkedList<Resource>();
    ClosableIterator<QueryRow> it = table.iterator();
    while(it.hasNext()) {
      Resource res = it.next().getValue("res").asResource();
      result.add(res);
    }
    it.close();
View Full Code Here

    Object[] aslabels = new String[this.queries.length];
   
    for(int i = 0; i < aslabels.length; i++) {
      StringBuilder sb = new StringBuilder();
     
      QueryResultTable table = m.querySelect(String.format(this.queries[i], param), "SPARQL");
      ClosableIterator<QueryRow> it = table.iterator();
     
      while(it.hasNext()) {
        QueryRow row = it.next();
        sb.append(row.getLiteralValue("value")).append(", ");
      }
View Full Code Here

  {
    String query = SscfRdfQuery.RDF_FILTER_GET_UNLINKED.toString();
   
    //QueryResultsTable results = SesameDbFace.getDbFace().performTableQuery(query);
   
    QueryResultTable results = null;
    try
    {
      results = DbFace.getModel().querySelect(query,"SPARQL");
    }
    catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    int i = 0;
   
    if(results!=null){
      for(QueryRow qr: results) {
       
        String uri = qr.getValue(results.getVariables().get(0)).toString();
       
        XfoafSscfResource xfsr = XfoafSscfResource.getXfoafSscfResource(uri);
        if(xfsr!=null)
          xfsr.remove();
      }
View Full Code Here

    }
  }
 
  protected void showRawSuggestions(String mbox) {

    QueryResultTable it;
    try {
      System.out.println("QUERY= " + String.format(querySuggestions, mbox));
      it = model.querySelect(String.format(selectSuggestions, mbox),"SPARQL");
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    for(QueryRow qr: it)
    {
     
      for(int i=0;i<3;i++)
      {
        try {
          if (qr.getValue(it.getVariables().get(i)).toString() != null) {
            System.out.print(qr.getValue(it.getVariables().get(i)));
          } else {
            System.out.print("null");
          }
        } catch(Exception e) {break;}
      }
View Full Code Here

        try {
          Object desc = getGraphPropertyValue(XFOAF.description);
          this.description = (description != null) ? desc.toString()
              : null;
       
          QueryResultTable rt = model.querySelect(RdfQuery.RDFQ_OBJ_QUERY.toString(this.resource, XFOAF.wordNetClassification), "SPARQL");
          wordNetClassification.clear();
     
          Collection<ThesaurusContext> thesColl = Thesauri.getInstance().getContexts();
          for(QueryRow qr: rt){
            String qv = qr.getValue(rt.getVariables().get(0)).toString();
           
            ThesaurusEntry thesEntry=null;
            for(ThesaurusContext thes:thesColl)
            {
              if(qv.contains(thes.getNamespaceURI()))
              {
                thesEntry = thes.getEntryByUri(qv,null);
              }
            }
           
            if(thesEntry!=null)
              wordNetClassification.add(thesEntry);
          }
         
          rt = model.querySelect(RdfQuery.RDFQ_OBJ_QUERY.toString(this.resource,XFOAF.jontoClassification), "SPARQL");
          jontoClassification.clear();
         
          Collection<TaxonomyContext<TaxonomyEntry>> cnts = Taxonomies.getInstance().getContexts();
          for(QueryRow qr: rt){
            String qv = qr.getValue(rt.getVariables().get(0)).toString();
           
            TaxonomyEntry taxEntry=null;
            for(TaxonomyContext<TaxonomyEntry> cnt:cnts)
            {
              if(qv.contains(cnt.getNamespaceURI()))
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.QueryResultTable

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.