@Override public void lock() throws LockException { this.locked = true; this.jenaModel.enterCriticalSection(true); }
/** * {@inheritDoc} */ @Override public void enterCriticalSection(boolean readLockRequested) { super.object.enterCriticalSection(readLockRequested); }
public void enterCriticalSection(boolean readLockRequested) { model.enterCriticalSection(readLockRequested); }
@Override public void generate(final DataGenParams params) throws IOException { model.enterCriticalSection( Lock.WRITE ); try { super.generate( params ); } finally { model.leaveCriticalSection(); } }
graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); log.debug(String.format("Running query %s", queryString));
/** * Returns the number of statements in the graph. * <p> * XXX AT: this size may not be equal to the number of statements retrieved via getStatements() because it counts * each statement property. * * @return integer number of statements in the graph */ @Override public Long size() { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); return graph.size(); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@Override public boolean write(OutputStream out, String lang, String base) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.WRITE); graph.write(out, lang, base); // default to true return true; } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@Override public boolean read(InputStream in, String lang, String base) { // XXX AT: maybe update namespaces in case some new appeared Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); graph.read(in, base, lang); // default to true return true; } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@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(); } } }
@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)) { // remove duplicates res.add(predicate); } } return res; } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@Override public List<Statement> getStatements() { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); StmtIterator it = graph.listStatements(); return getNXRelationsStatements(graph, it.toList()); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.WRITE); for (Statement nuxStmt : statements) { com.hp.hpl.jena.graph.Node subject = getJenaNode(nuxStmt.getSubject());
@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(); } } }
@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(); } } }
@Override public boolean hasResource(Resource resource) { if (resource == null) { return false; } Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); com.hp.hpl.jena.graph.Node jenaNodeInst = getJenaNode(resource); RDFNode jenaNode = graph.asRDFNode(jenaNodeInst); return graph.containsResource(jenaNode); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@Override public List<Statement> getStatements(Statement statement) { Model graph = null; GraphConnection graphConnection = null; try { graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.READ); SimpleSelector selector = getJenaSelector(graph, statement); StmtIterator it = graph.listStatements(selector); return getNXRelationsStatements(graph, it.toList()); } finally { if (graph != null) { graph.leaveCriticalSection(); } if (graphConnection != null) { graphConnection.close(); } } }
@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(); } } }
graphConnection = openGraph(); graph = graphConnection.getGraph(); graph.enterCriticalSection(Lock.WRITE); for (Statement nuxStmt : statements) { com.hp.hpl.jena.graph.Node subject = getJenaNode(nuxStmt.getSubject());