예제 #1
0
 @Override
 public boolean hasStatement(Statement statement) {
   if (statement == null) {
     return false;
   }
   Model graph = null;
   GraphConnection graphConnection = null;
   try {
     graphConnection = openGraph();
     graph = graphConnection.getGraph();
     graph.enterCriticalSection(Lock.READ);
     SimpleSelector selector = getJenaSelector(graph, statement);
     return graph.contains(selector.getSubject(), selector.getPredicate(), selector.getObject());
   } finally {
     if (graph != null) {
       graph.leaveCriticalSection();
     }
     if (graphConnection != null) {
       graphConnection.close();
     }
   }
 }
예제 #2
0
 @Override
 public List<Node> getObjects(Node subject, Node predicate) {
   Model graph = null;
   GraphConnection graphConnection = null;
   try {
     graphConnection = openGraph();
     graph = graphConnection.getGraph();
     graph.enterCriticalSection(Lock.READ);
     SimpleSelector selector = getJenaSelector(graph, new StatementImpl(subject, predicate, null));
     NodeIterator it = graph.listObjectsOfProperty(selector.getSubject(), selector.getPredicate());
     List<Node> res = new ArrayList<Node>();
     while (it.hasNext()) {
       res.add(getNXRelationsNode(it.nextNode().asNode()));
     }
     return res;
   } finally {
     if (graph != null) {
       graph.leaveCriticalSection();
     }
     if (graphConnection != null) {
       graphConnection.close();
     }
   }
 }