示例#1
0
 @Override
 public void clear() {
   Model graph = null;
   GraphConnection graphConnection = null;
   try {
     graphConnection = openGraph();
     graph = graphConnection.getGraph();
     graph.enterCriticalSection(Lock.READ);
     graph.removeAll();
     // XXX AT: remove reification quadlets explicitly
     RSIterator it = graph.listReifiedStatements();
     List<ReifiedStatement> rss = new ArrayList<ReifiedStatement>();
     while (it.hasNext()) {
       rss.add(it.nextRS());
     }
     for (ReifiedStatement rs : rss) {
       graph.removeReification(rs);
     }
   } finally {
     if (graph != null) {
       graph.leaveCriticalSection();
     }
     if (graphConnection != null) {
       graphConnection.close();
     }
   }
 }
示例#2
0
 @Override
 public void remove(List<Statement> statements) {
   Model graph = null;
   GraphConnection graphConnection = null;
   try {
     graphConnection = openGraph();
     graph = graphConnection.getGraph();
     graph.enterCriticalSection(Lock.WRITE);
     for (Statement nuxStmt : statements) {
       com.hp.hpl.jena.graph.Node subject = getJenaNode(nuxStmt.getSubject());
       com.hp.hpl.jena.graph.Node predicate = getJenaNode(nuxStmt.getPredicate());
       com.hp.hpl.jena.graph.Node object = getJenaNode(nuxStmt.getObject());
       Triple jenaTriple = Triple.create(subject, predicate, object);
       com.hp.hpl.jena.rdf.model.Statement jenaStmt = graph.asStatement(jenaTriple);
       graph.remove(jenaStmt);
       // remove properties
       RSIterator it = graph.listReifiedStatements(jenaStmt);
       while (it.hasNext()) {
         ReifiedStatement rs = it.nextRS();
         rs.removeProperties();
       }
       // remove quadlets
       graph.removeAllReifications(jenaStmt);
       // graph.removeReification(reifiedStmt);
     }
   } finally {
     if (graph != null) {
       graph.leaveCriticalSection();
     }
     if (graphConnection != null) {
       graphConnection.close();
     }
   }
 }
示例#3
0
 /**
  * Find any existing reified statement that reifies a givem statement. If there isn't one, create
  * one.
  *
  * @param s a Statement for which to find [or create] a reification
  * @return a reification for s, re-using an existing one if possible
  */
 public Resource getAnyReifiedStatement(Statement s) {
   RSIterator it = listReifiedStatements(s);
   if (it.hasNext())
     try {
       return it.nextRS();
     } finally {
       it.close();
     }
   else return createReifiedStatement(s);
 }