static Set<Resource> subjects(Model model, Property p, RDFNode r) {
   Set<Resource> subjects = new HashSet<>();
   ResIterator it = model.listSubjectsWithProperty(p, r);
   while (it.hasNext()) subjects.add(it.next().asResource());
   it.close();
   return subjects;
 }
예제 #2
0
 @Override
 public List<Node> getSubjects(Node predicate, Node object) {
   Model graph = null;
   GraphConnection graphConnection = null;
   try {
     graphConnection = openGraph();
     graph = graphConnection.getGraph();
     graph.enterCriticalSection(Lock.READ);
     SimpleSelector selector = getJenaSelector(graph, new StatementImpl(null, predicate, object));
     ResIterator it =
         graph.listSubjectsWithProperty(selector.getPredicate(), selector.getObject());
     List<Node> res = new ArrayList<Node>();
     while (it.hasNext()) {
       res.add(getNXRelationsNode(it.nextResource().asNode()));
     }
     return res;
   } finally {
     if (graph != null) {
       graph.leaveCriticalSection();
     }
     if (graphConnection != null) {
       graphConnection.close();
     }
   }
 }
예제 #3
0
 private String getConfigsUriFromPrefix(String pre) {
   ResIterator subjects = config.listSubjectsWithProperty(EYE.prefix, config.createLiteral(pre));
   if (subjects.hasNext()) {
     StmtIterator uris = config.listStatements(subjects.nextResource(), EYE.nsURI, (RDFNode) null);
     if (uris.hasNext()) return uris.nextStatement().getObject().asNode().getLiteralLexicalForm();
   }
   return null; // Return null otherwise
 }