@Test public void testGetPredicates() { graph.add(statements); List<Node> expected; List<Node> res; res = graph.getPredicates(doc2, doc1); Collections.sort(res); expected = new ArrayList<Node>(); expected.add(isBasedOn); Collections.sort(expected); assertEquals(expected, res); res = graph.getPredicates(doc2, null); Collections.sort(res); expected = new ArrayList<Node>(); expected.add(isBasedOn); expected.add(references); Collections.sort(expected); assertEquals(expected, res); res = graph.getPredicates(null, doc1); Collections.sort(res); expected = new ArrayList<Node>(); expected.add(isBasedOn); Collections.sort(expected); assertEquals(expected, res); res = graph.getPredicates(null, null); Collections.sort(res); expected = new ArrayList<Node>(); expected.add(isBasedOn); expected.add(references); Collections.sort(expected); assertEquals(expected, res); }
@Override public List<Node> getPredicates(Node subject, Node object) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, new StatementImpl( subject, null, object)); StmtIterator it = graph.listStatements(selector); List<Statement> statements = getNXRelationsStatements(graph, it.toList()); List<Node> res = new ArrayList<Node>(); for (Statement stmt : statements) { Node predicate = stmt.getPredicate(); if (!res.contains(predicate)) { res.add(predicate); } } return res; } catch (Exception e) { throw wrapException(e); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
JenaGraph implements Graph { @Override public List<Node> getPredicates(Node subject, Node object) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, new StatementImpl( subject, null, object)); StmtIterator it = graph.listStatements(selector); List<Statement> statements = getNXRelationsStatements(graph, it.toList()); List<Node> res = new ArrayList<Node>(); for (Statement stmt : statements) { Node predicate = stmt.getPredicate(); if (!res.contains(predicate)) { res.add(predicate); } } return res; } catch (Exception e) { throw wrapException(e); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } } }
JenaGraph implements Graph { @Override public List<Node> getPredicates(Node subject, Node object) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, new StatementImpl( subject, null, object)); StmtIterator it = graph.listStatements(selector); List<Statement> statements = getNXRelationsStatements(graph, it.toList()); List<Node> res = new ArrayList<Node>(); for (Statement stmt : statements) { Node predicate = stmt.getPredicate(); if (!res.contains(predicate)) { res.add(predicate); } } return res; } catch (Exception e) { throw wrapException(e); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }  }
JenaGraph implements Graph { @Override public List<Node> getPredicates(Node subject, Node object) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, new StatementImpl( subject, null, object)); StmtIterator it = graph.listStatements(selector); List<Statement> statements = getNXRelationsStatements(graph, it.toList()); List<Node> res = new ArrayList<Node>(); for (Statement stmt : statements) { Node predicate = stmt.getPredicate(); if (!res.contains(predicate)) { res.add(predicate); } } return res; } catch (Exception e) { throw wrapException(e); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }  @Override void setDescription(GraphDescription graphDescription); void setNamespaces(Map<String, String> namespaces); @Override Map<String, String> getNamespaces(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate,
            Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override Long size(); @Override void clear(); @Override QueryResult query(String queryString, String language, String baseURI); @Override boolean read(InputStream in, String lang, String base); @Override boolean read(String path, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); @Override boolean write(String path, String lang, String base); }
JenaGraph implements Graph { @Override public List<Node> getPredicates(Node subject, Node object) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, new StatementImpl( subject, null, object)); StmtIterator it = graph.listStatements(selector); List<Statement> statements = getNXRelationsStatements(graph, it.toList()); List<Node> res = new ArrayList<Node>(); for (Statement stmt : statements) { Node predicate = stmt.getPredicate(); if (!res.contains(predicate)) { res.add(predicate); } } return res; } catch (Exception e) { throw wrapException(e); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }  @Override void setDescription(GraphDescription graphDescription); void setNamespaces(Map<String, String> namespaces); @Override Map<String, String> getNamespaces(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate,
            Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override Long size(); @Override void clear(); @Override QueryResult query(String queryString, String language, String baseURI); @Override boolean read(InputStream in, String lang, String base); @Override boolean read(String path, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); @Override boolean write(String path, String lang, String base);  }