Package org.ontoware.rdf2go.model

Examples of org.ontoware.rdf2go.model.QueryResultTable


   * @param q
   * @param field
   * @return
   */
  public static Node[] processVectorQuery(String q, String field) {
    QueryResultTable result = S3BRepository.getInstance().getModel().querySelect(q, "SPARQL");
   
    ClosableIterator<QueryRow> it =  result.iterator();
    Set<Node> snodes = new HashSet<Node>();
   
    while(it.hasNext()) {
      QueryRow row = it.next();
      snodes.add(row.getValue(field));
View Full Code Here


   * @param f1
   * @param f2
   * @return
   */
  public static Node[][] processArrayQuery(String q, String f1, String f2) {
    QueryResultTable result = S3BRepository.getInstance().getModel().querySelect(q, "SPARQL");
   
    ClosableIterator<QueryRow> it =  result.iterator();
    Map<Node,Node> snodes = new HashMap<Node,Node>();
   
    while(it.hasNext()) {
      QueryRow row = it.next();
      snodes.put(row.getValue(f1), row.getValue(f2));
View Full Code Here

    if(_model!=null) innerModel = _model;
    else innerModel = DbFace.getModel();
   
    try
    {
      QueryResultTable results = innerModel.querySelect(RdfQuery.RDF_GET_USER_SIOC_DIR.toString(
        S3B_SSCF.Directory , dirLabel, ownerMbox),"SPARQL");
      ClosableIterator<QueryRow> it = results.iterator();
      if (it.hasNext()) {
        QueryRow qr = it.next();
        if(qr.getValue(results.getVariables().get(0))!=null)
          return qr.getValue(results.getVariables().get(0)).toString();
      }
    }
    catch (Exception e)
    {
      // ignore
View Full Code Here

   
    /*//all keywords of the posts
    Map<String, Collection<String>> keywords = new HashMap<String, Collection<String>>();*/
   
    //get the triples from DB (sesame)
    QueryResultTable results = null;
    try
    {
      results = model.querySelect(RdfQuery.RDFQ_GIVEN_RESOURCE_POST.toString(
          SIOC.postedResource, SIOC.Post, SIOC.postedWhen, SIOC.postedBy, SIOC.postBody, SIOC.topic, SIOC.hasReply, SIOC.title, uri)
          ,"SPARQL");
    }
    catch (Exception e)
    {
      return null;
    }
   
    //TODO:chang numbers of parameters to names
    for(QueryRow qr:results) {
     
      Person i_person = PersonFactory.findPerson(qr.getValue(results.getVariables().get(3)).toString());
      if (i_person == null) {
        i_person = PersonFactory.createPerson(qr.getValue(results.getVariables().get(3)).toString(), null, false);
      }
      String i_postUri = qr.getValue(results.getVariables().get(0)).toString();
      String i_createdAt = qr.getLiteralValue(results.getVariables().get(2));
      String i_body = qr.getLiteralValue(results.getVariables().get(4));
      String i_keyword = null;
      try {
        i_keyword = qr.getLiteralValue(results.getVariables().get(5));
      } catch(Exception e) {/* ignore */}
      String i_reply = null;
      try {
        i_reply = qr.getLiteralValue(results.getVariables().get(6));
      } catch(Exception e) {/* ignore */}
      String i_title = null;
      try {
        i_title = qr.getLiteralValue(results.getVariables().get(7));
      } catch(Exception e) {/* ignore */}
     
      // build tree of the posts
      if (allPosts.get(i_postUri) == null) {
        SiocPostBean post = new SiocPostBean(i_postUri,uri,i_person,i_createdAt,i_title,i_body);
View Full Code Here

   */
  public List<Person> getPostsAuthors() {
    List<Person> authors = new ArrayList<Person>();
   
    // get the list of the authors' mboxes of the posts on that resource
    QueryResultTable results = null;
    try
    {
      results = model.querySelect(RdfQuery.RDF_GET_POSTS_AUTHORS_ON_RESOURCE.toString(uri),"SPARQL");
    }
    catch (Exception e)
    {
      //will be catched later
    }
   
   
    if(results!=null) {
      for(QueryRow qr:results) {
 
        Person person = PersonFactory.findPerson(qr.getValue(results.getVariables().get(0)).toString());
        if (person == null) {
          person = PersonFactory.createPerson(qr.getValue(results.getVariables().get(0)).toString(), null, false);
        }
       
        boolean isOnList = false;
        for (Person p : authors) {
          if (person.getMbox().toString().equals(p.getMbox())) {
            isOnList = true;
            //System.out.println("bedzie break");
            break;
          }
        }
        // if current author is not on the list yet, add it
        if (isOnList == false) {
         
          try
          {
            QueryResultTable results2 = model.querySelect(RdfQuery.RDF_GET_PERSON_INFO.toString( person.getMbox().toString()),"SPARQL");
           
            if (results2 != null) {
              for(QueryRow qr2 : results2) {
           
                try {
                  if (qr2.getLiteralValue(results2.getVariables().get(1)) != null) {
                    //System.out.println("..."+results2.getValue(0, 1).toString());
                    person.setName(qr2.getLiteralValue(results2.getVariables().get(1)));
                  }
                } catch(Exception e) {/* ignore */}
                try {
                  if (qr2.getLiteralValue(results2.getVariables().get(2)) != null) {
                    person.setGivenname(qr2.getLiteralValue(results2.getVariables().get(2)));
                  }
                } catch(Exception e) {/* ignore */}
                try {
                  if (qr2.getLiteralValue(results2.getVariables().get(3)) != null) {
                    person.setFamily_name(qr2.getLiteralValue(results2.getVariables().get(3)));
                  }
                } catch(Exception e) {/* ignore */}
              }
            }
            authors.add(person);
 
View Full Code Here

   
    return content.iterator();
  }

  public int listIsInSize() {
    QueryResultTable results = model.querySelect(RdfQuery.RDFQ_OBJ_QUERY.toString(
        this.resource,S3B_SSCF.isIn),"SPARQL");
   
    if(results!=null)
      return IteratorUtils.toArray(results.iterator()).length;
    return 0;
  }
View Full Code Here

         
          query.append(sb);
         
          System.out.println("final qyery"+query);
         
          QueryResultTable results = null;
          try
          {
            results = DbFace.getModel().querySelect(query.toString(),"SPARQL");
          }
          catch (Exception e1)
          {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
       
       
          if(results!=null&&!inJson)
          {
            for(QueryRow qr : results) {
           
              String uri =  qr.getValue(results.getVariables().get(0)).toString();
              if(!avoidDuplicates.contains(uri))
              {
                FilterResult fr = new FilterResult();
                fr.setResourceUri(qr.getValue(results.getVariables().get(0)).toString());
                fr.setResourceType(qr.getValue(results.getVariables().get(1)).toString());
                fr.setLabel(qr.getLiteralValue(results.getVariables().get(2)));
                try {
                  fr.setContent(qr.getLiteralValue(results.getVariables().get(3)));
                }
                catch (Exception e)
                {
                  fr.setContent(null);
                }
                try
                {
                  fr.setCreator(qr.getLiteralValue(results.getVariables().get(4)));
                }
                catch (Exception e)
                {
                  fr.setCreator(null);
                }
               
                result.add(fr);
                avoidDuplicates.add(uri);
              }
            }
          }
          else if(results!=null)
          {
            for(QueryRow qr : results) {
             
              String uri =  qr.getValue(results.getVariables().get(0)).toString();
              if(!avoidDuplicates.contains(uri))
              {
                JSONObject jo = new JSONObject();
                jo.put("uri", qr.getValue(results.getVariables().get(0)).toString().toString());
                jo.put("type", qr.getValue(results.getVariables().get(1)).toString().toString());
                jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
                try
                {
                  jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
                }
                catch (Exception e)
                {
                  jo.put("content", null);
                }
                try
                {
                  jo.put("creator", qr.getLiteralValue(results.getVariables().get(4)));
                }
                catch (Exception e)
                {
                  jo.put("creator", null);
                }
View Full Code Here

    {
      for(TaxonomyEntry entry:entries)
      {
        String query = FilterModes.ModeTax.getQuery(this.searchType, this.person, entry.getURI().toString(),0);         
          //this.searchType.getTaxonomyQuery(this.person,entry.getURI());
        QueryResultTable results=null;
        try
        {
          results = DbFace.getModel().querySelect(query,"SPARQL");
        }
        catch (Exception e1)
        {
          //
        }
       
        if(results!=null&&!inJson)
        {
          for(QueryRow qr:results) {
           
            FilterResult fr = new FilterResult();
            fr.setResourceUri(qr.getValue(results.getVariables().get(0)).toString());
            fr.setResourceType(qr.getValue(results.getVariables().get(1)).toString());
            fr.setLabel(qr.getLiteralValue(results.getVariables().get(2)));
            try {
              fr.setContent(qr.getLiteralValue(results.getVariables().get(3)));
            } catch(Exception e) {
              fr.setContent(null);
            }
            try {
              fr.setCreator(qr.getValue(results.getVariables().get(4)).toString());
            }
            catch (Exception e) {
              fr.setCreator(null);
            }
            fr.setGroup(entry.getURI().toString());
           
            result.add(fr);
          }
        }
        else if(results!=null)
        {
          int i=0;
          for(QueryRow qr:results) {
            i++;
            JSONObject jo = new JSONObject();

            jo.put("uri", qr.getValue(results.getVariables().get(0)).toString());
            jo.put("type",qr.getValue(results.getVariables().get(1)).toString());
            jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
            try {
              jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
            } catch(Exception e) {
              jo.put("content", null);
            }
            try {
              jo.put("creator", qr.getValue(results.getVariables().get(4)).toString());
            } catch (Exception e){
              jo.put("creator", null);
            }
            jo.put("group",entry.getURI().toString());
           
View Full Code Here

    //QueryResultsTable result = SesameDbFace.getDbFace().performTableQuery(query);
    System.out.println("query: "+query);
   
    try
    {
      QueryResultTable result = DbFace.getModel().querySelect(query,"SPARQL");
       
      for(QueryRow qr: result) {
       
        String person = null;
        List<String> path = new ArrayList<String>();
       
        //fetch the path from table
        Object[] oneResult = new Object[maxDepth];
        int nb=0;
        for(int i=0;i<maxDepth;i++)
        {
          try {
            oneResult[i] = qr.getValue(result.getVariables().get(i));
            nb++;
          } catch(Exception e) {break;}
        }
       
        for (int j=(nb-1);j>=0;j--)
View Full Code Here

      //annotated with it
      for(KOSEntry resOne: res)
      {
        String query = FilterModes.ModeWordnet.getQuery(this.searchType, person, resOne.getURI().toString(),0);
          //this.searchType.getWordNetQuery(this.person,wncOne.getURI());
        QueryResultTable results=null;
        try
        {
          results = DbFace.getModel().querySelect(query,"SPARQL");
        }
        catch (Exception e1)
        {
          //
        }
       
        if(results!=null&&!inJson)
        {
          for(QueryRow qr:results) {
           
            FilterResult fr = new FilterResult();
            fr.setResourceUri(qr.getValue(results.getVariables().get(0)).toString());
            fr.setResourceType(qr.getValue(results.getVariables().get(1)).toString());
            fr.setLabel(qr.getLiteralValue(results.getVariables().get(2)));
            try {
              fr.setContent(qr.getLiteralValue(results.getVariables().get(3)));
            } catch(Exception e) {
              fr.setContent(null);
            }
            try {
              fr.setCreator(qr.getValue(results.getVariables().get(4)).toString());
            }
            catch (Exception e) {
              fr.setCreator(null);
            }
            fr.setGroup(resOne.getURI().toString());
           
            result.add(fr);
          }
        }
        else if(results!=null)
        {
          int i=0;
          for(QueryRow qr:results) {
            i++;
            JSONObject jo = new JSONObject();

            jo.put("uri", qr.getValue(results.getVariables().get(0)).toString());
            jo.put("type",qr.getValue(results.getVariables().get(1)).toString());
            jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
            try {
              jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
            } catch(Exception e) {
              jo.put("content", null);
            }
            try {
              jo.put("creator", qr.getValue(results.getVariables().get(4)).toString());
            } catch (Exception e){
              jo.put("creator", null);
            }
            jo.put("group",resOne.getURI().toString());
           
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.