Examples of StatementIterator


Examples of org.openrdf.sesame.sail.StatementIterator

   
    return updateElementCode(myGraph, oldobj, newobj);
  }
 
  private Thesaurus updateElementCode(Graph myGraph, URI oldobj, URI newobj) {
    StatementIterator iterStSubject = myGraph.getStatements(oldobj,null,null);
    while(iterStSubject.hasNext()){
      AtomicReference<Statement> st = new AtomicReference<Statement>(iterStSubject.next());
      myGraph.add(newobj, st.get().getPredicate(), st.get().getObject());
    }   
   
    StatementIterator iterStObject = myGraph.getStatements(null,null,oldobj);
    while(iterStObject.hasNext()){
      Statement st = iterStObject.next();
      myGraph.add(st.getSubject(), st.getPredicate(), newobj);
    }
    myGraph.remove(oldobj,null,null);
    myGraph.remove(null,null,oldobj);
    return this;
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

        return removeElement(myGraph, subject);
    }
   
  private Thesaurus removeElement(Graph myGraph, URI subject)
      throws AccessDeniedException {
    StatementIterator iter = myGraph.getStatements(subject, null, null);
        while (iter.hasNext()) {
            AtomicReference<Statement> st = new AtomicReference<Statement>(iter.next());
            if (st.get().getObject() instanceof BNode) {
                BNode node = (BNode) st.get().getObject();
                repository.getGraph().remove(node, null, null);
            }
        }
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

        // Get subject (URI)
        URI subject = myFactory.createURI(keyword.getUriCode());

        // Remove old labels
        StatementIterator iter = myGraph.getStatements(subject, predicatePrefLabel, null);
        removeMatchingLiterals(replace, myGraph, iter, keyword.getValues().keySet());
       
        // remove old scopeNote
        iter = myGraph.getStatements(subject, predicateScopeNote, null);
        removeMatchingLiterals(replace, myGraph, iter, keyword.getDefinitions().keySet());

        // add updated Labels
        Set<Entry<String, String>> values = keyword.getValues().entrySet();
        for (Entry<String, String> entry : values) {
            String language = toiso639_1_Lang(entry.getKey());
            Value valueObj = myFactory.createLiteral(entry.getValue(), language);
            myGraph.add(subject, predicatePrefLabel, valueObj );
           
        }
        // add updated Definitions/Notes
        Set<Entry<String, String>> definitions = keyword.getDefinitions().entrySet();
        for (Entry<String, String> entry : definitions) {
            String language = toiso639_1_Lang(entry.getKey());
            Value definitionObj = myFactory.createLiteral(entry.getValue(), language);
            myGraph.add(subject, predicateScopeNote, definitionObj );
           
        }

      // update bbox
        if(replace || !(keyword.getCoordEast() + keyword.getCoordNorth() + keyword.getCoordWest() + keyword.getCoordSouth()).trim().isEmpty()) {
          String namespaceGml = "http://www.opengis.net/gml#";
          URI predicateBoundedBy = myFactory.createURI(namespaceGml, "BoundedBy");
          URI predicateLowerCorner = myFactory.createURI(namespaceGml, "lowerCorner");
          URI predicateUpperCorner = myFactory.createURI(namespaceGml, "upperCorner");
         
          BNode subjectGml = null;
          iter = myGraph.getStatements(subject, predicateBoundedBy, null);
          while (iter.hasNext()) {
              AtomicReference<Statement> st = new AtomicReference<Statement>(iter.next());
              if (st.get().getObject() instanceof BNode) {
                  subjectGml = (BNode) st.get().getObject();
              }
          }
          if (subjectGml != null) {
              // lowerCorner
              iter = myGraph.getStatements(subjectGml, predicateLowerCorner, null);
              while (true) {
                  if (!(iter.hasNext())) {
                      break;
                  }
                  AtomicReference<Statement> st = new AtomicReference<Statement>(iter.next());
                  myGraph.remove(st.get());
                  break;
              }
              // upperCorner
              iter = myGraph.getStatements(subjectGml, predicateUpperCorner, null);
              while (true) {
                  if (!(iter.hasNext())) {
                      break;
                  }
                  AtomicReference<Statement> st = new AtomicReference<Statement>(iter.next());
                  myGraph.remove(st.get());
                  break;
              }
              // create the new statements
              Literal lowerCorner = myFactory.createLiteral(keyword.getCoordWest() + " " + keyword.getCoordSouth());
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

   * @throws AccessDeniedException
   */
  protected void computerPath(Graph g, Value action, List<Integer> _usedPath) throws AccessDeniedException {
    Value axis = null;
    Value newaction = action;
    StatementIterator it;
    Set<Value> antiloop = new HashSet<Value>();
    Graph globalGraph = Repository.MAIN_REPOSITORY.getLocalRepository().getGraph();

    while(newaction != null) {
      if(newaction instanceof Resource && !antiloop.contains(newaction)) {
        antiloop.add(newaction);

        it = globalGraph.getStatements((Resource)newaction, MultiBeeBrowseRDF.MBB_FOLLOWSALONGAXIS.getURI(g), null);
       
        if(it != null && it.hasNext()) {
          axis = it.next().getObject();
       
          it = globalGraph.getStatements((Resource)newaction, MultiBeeBrowseRDF.MBB_FOLLOWS.getURI(g), null);
         
          if(it != null && it.hasNext())
            newaction = it.next().getObject();
       
          if(axis instanceof Literal)
          _usedPath.add(0, Integer.valueOf(((Literal)axis).getLabel()));
         
          continue; //start the loop over with new action
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

      Repository.logger.severe("predefined properties file IO problem"+e);
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied predefined properties file"+e);
    }
   
    StatementIterator stmtit = null;
    try {
      stmtit = tmprep.getGraph().getStatements();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to temporal graph"+e);
    }
    Graph g = null;
    try {
      g = Repository.MAIN_REPOSITORY.getLocalRepository().getGraph();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to main graph"+e);
    }
   
    if(g!=null) {
      //adding all new to the main graph
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          if(!g.contains(stmt)) {
            g.add(stmt);
          }
        }
     
      //add all to MAP_CONCEPTS_PREDEFINED
      stmtit = g.getStatements(null, property.getURI(g), null);
     
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          MAP_CONCEPTS_PREDEFINED.put(stmt.getObject().toString(), stmt.getSubject().toString());
          INVERSE_MAP_CONCEPTS_PREDEFINED.put(stmt.getSubject().toString(), stmt.getObject().toString());
          Repository.logger.finer("adding new concept def: <"+stmt.getSubject().toString()+","+stmt.getObject().toString()+">");
        }
    }
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

      Repository.logger.severe("predefined properties file IO problem"+e);
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied predefined properties file"+e);
    }
   
    StatementIterator stmtit = null;
    try {
      stmtit = tmprep.getGraph().getStatements();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to temporal graph"+e);
    }
    Graph g = null;
    try {
      g = Repository.MAIN_REPOSITORY.getLocalRepository().getGraph();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to main graph"+e);
    }
   
    if(g!=null) {
      //adding all new to the main graph
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          if(!g.contains(stmt)) {
            g.add(stmt);
          }
        }
     
      //add all to MAP_CONCEPTS_PREDEFINED
      stmtit = g.getStatements(null, property.getURI(g), null);
     
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          String key = stmt.getObject().toString();
         
          List<String> tmp = MAP_CONCEPTS_PREDEFINED.get(key);
          if(tmp == null){
            tmp = new ArrayList<String>();
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

      //--B
      if((axisPath.getPath().size() - 1) == _usedPath.size())//--B.1
        _usedPath.add(axisPath.getPath().get(axisPath.getPath().size()-1));
      else if(lastAction != null){//--B.2
        StatementIterator stit = lr2.getGraph().getStatements(lastAction, MultiBeeBrowseRDF.MBB_ISFOLLOWEDSALONGAXIS.getURI(lr2.getGraph()), null);
        Set<Integer> saxis = new HashSet<Integer>();
       
        while(stit.hasNext()) {
          saxis.add(Integer.parseInt(((Literal)stit.next().getObject()).getLabel()));
        }
       
        //--C
        if(saxis.size() >= 6)//--C.1
          _usedPath.add(0);
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

        obj = g.getValueFactory().createURI(value);
    }
   
    if(prop != null)
    for(URI u : prop){
      StatementIterator it = g.getStatements(null, u, obj);
     
      if(it!=null)
        while(it.hasNext())
          result.add(it.next().getSubject());
    }
   
    return result;
  }
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

   * @return
   */
  public static final Collection<KeyValuePair<URI, Value>> describeResource(Graph g, Resource resource){
    Collection<KeyValuePair<URI, Value>> result = new ArrayList<KeyValuePair<URI,Value>>();
   
    StatementIterator it = g.getStatements(resource, null, null);
   
    if(it!=null)
    while(it.hasNext()) {
      Statement s = it.next();
      result.add(new KeyValuePair<URI, Value>(s.getPredicate(), s.getObject()));
    }
   
    return result;
  }
View Full Code Here

Examples of org.openrdf.sesame.sail.StatementIterator

    int i = 0;
    Value vresult = null;
    Graph g = lr.getGraph();
   
    //--get first on the list
    StatementIterator it = g.getStatements(context, MultiBeeBrowseRDF.MBB_HASFIRSTACTION.getURI(g), (Resource)null);
    if(it!=null && it.hasNext())
      vresult = it.next().getObject();

    Set<Value> snoloop = new HashSet<Value>();
   
    for(int axis : this.path) {
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.