public void testConstructionByURI() {
   ReifiedStatement rs = model.createReifiedStatement("spoo:handle", SPO);
   ReifiedStatement rs2 = SPO.createReifiedStatement("spoo:gripper");
   assertEquals("recover statement (URI)", SPO, rs.getStatement());
   assertEquals("recover URI", "spoo:handle", rs.getURI());
   assertEquals("recover URI", "spoo:gripper", rs2.getURI());
 }
Esempio n. 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();
     }
   }
 }
Esempio n. 3
0
 /**
  * If _n_ is a ReifiedStatement, create a local copy of it, which will force the underlying
  * reifier to take note of the mapping.
  */
 private void noteIfReified(RDFNode n) {
   if (n.canAs(ReifiedStatement.class)) {
     ReifiedStatement rs = n.as(ReifiedStatement.class);
     createReifiedStatement(rs.getURI(), rs.getStatement());
   }
 }
Esempio n. 4
0
 /**
  * Remove a given reification from this model. Other reifications of the same statement are
  * untouched.
  *
  * @param rs the reified statement to be removed
  */
 public void removeReification(ReifiedStatement rs) {
   reifier.remove(rs.asNode(), rs.getStatement().asTriple());
 }
 public void testStatementAndModel(String title, ReifiedStatement rs, Model m, Statement st) {
   assertEquals(title + ": recover statement", st, rs.getStatement());
   assertEquals(title + ": recover model", m, rs.getModel());
 }
 public void testConversion() {
   final String uri = "spoo:handle";
   model.createReifiedStatement(uri, SPO);
   ReifiedStatement rs2 = (ReifiedStatement) model.createResource(uri).as(ReifiedStatement.class);
   assertEquals("recover statement", SPO, rs2.getStatement());
 }