public boolean hasDeprecated() { return deprecated != null && !deprecated.isEmpty(); } }
private CloseableIteration<? extends Statement, SailException> difference( CloseableIteration<? extends Statement, SailException> result, final Model excluded) { if (excluded.isEmpty()) { return result; } return new FilterIteration<Statement, SailException>(result) { protected boolean accept(Statement stmt) { return !excluded.contains(stmt); } }; }
public List<String> getURIs(URI type) { if (type == null) throw new IllegalArgumentException("The type cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); org.eclipse.rdf4j.model.URI uri = f.createURI(type.toString()); try { Model statements = repos.filter(null, null, uri); if (statements.isEmpty()) return Collections.emptyList(); List<String> units = new ArrayList<>(); for (Statement statement : statements) { units.add(statement.getSubject().toString()); } return units; } catch (Exception exception) { throw new IllegalStateException("Error while getting the units: " + exception.getMessage(), exception); } }
public List<String> getURIs(URI type) { if (type == null) throw new IllegalArgumentException("The type cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); org.eclipse.rdf4j.model.URI uri = f.createURI(type.toString()); try { Model statements = repos.filter(null, null, uri); if (statements.isEmpty()) return Collections.emptyList(); List<String> units = new ArrayList<>(); for (Statement statement : statements) { units.add(statement.getSubject().toString()); } return units; } catch (Exception exception) { throw new IllegalStateException("Error while getting the units: " + exception.getMessage(), exception); } }
private synchronized void flushStatements() throws RDFHandlerException { if (!stmtBySubject.isEmpty() || !blanks.isEmpty()) { flushNamespaces(); Statement st; while ((st = nextStatement()) != null) { delegate.handleStatement(st); } assert queueSize == 0; } }
private synchronized void flushStatements() throws RDFHandlerException { if (!stmtBySubject.isEmpty() || !blanks.isEmpty()) { flushNamespaces(); Statement st; while ((st = nextStatement()) != null) { delegate.handleStatement(st); } assert queueSize == 0; } }
private CloseableIteration<? extends Statement, SailException> union( CloseableIteration<? extends Statement, SailException> result, Model included) { if (included.isEmpty()) { return result; } final Iterator<Statement> iter = included.iterator(); CloseableIteration<Statement, SailException> incl; incl = new CloseableIteratorIteration<Statement, SailException>(iter); return new UnionIteration<Statement, SailException>(incl, result); }
public List<Unit> findUnits(String symbol) { if (symbol == null) throw new IllegalArgumentException("The symbol cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); Model statements = repos.filter(null, QUDT.ABBREVIATION, f.createLiteral(symbol, XMLSchema.STRING)); if (statements.isEmpty()) return Collections.emptyList(); List<Unit> foundUnits = new ArrayList<>(); for (Statement statement : statements) { Object type = statement.getSubject(); try { if (type instanceof org.eclipse.rdf4j.model.URI) { org.eclipse.rdf4j.model.URI typeURI = (org.eclipse.rdf4j.model.URI)type; foundUnits.add(getUnit(typeURI.toString())); } } catch (Exception exception) { // ignore } } return foundUnits; }
public List<Unit> findUnits(String symbol) { if (symbol == null) throw new IllegalArgumentException("The symbol cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); Model statements = repos.filter(null, QUDT.ABBREVIATION, f.createLiteral(symbol, XMLSchema.STRING)); if (statements.isEmpty()) return Collections.emptyList(); List<Unit> foundUnits = new ArrayList<>(); for (Statement statement : statements) { Object type = statement.getSubject(); try { if (type instanceof org.eclipse.rdf4j.model.URI) { org.eclipse.rdf4j.model.URI typeURI = (org.eclipse.rdf4j.model.URI)type; foundUnits.add(getUnit(typeURI.toString())); } } catch (Exception exception) { // ignore } } return foundUnits; }
/** * Performs the same checks as assertContains, but returns the Graph describing the resource as a result so you * do not need to perform a subsequent call to the database to get the data that is checked during containment * checks in the first place, thus saving a query to the database. * @param theObj the object that should exist. * @return The graph describing the resource * @throws IllegalArgumentException thrown if the object does not exist in the database */ private Model assertContainsAndDescribe(Object theObj) { assertStateOk(theObj); try { Model aGraph = DataSourceUtil.describe(getDataSource(), theObj); if (aGraph.isEmpty()) { throw new IllegalArgumentException("Entity does not exist: " + theObj); } return aGraph; } catch (QueryException e) { throw new PersistenceException(e); } }
private synchronized Set<Statement> queueBlankStatements(SubjectInContext key) { Model firstMatch = blanks.filter(key.getSubject(), null, null, key.getContext()); Model matches = firstMatch.isEmpty() ? blankReferences.filter(key.getSubject(), null, null, key.getContext()) : firstMatch; if (matches.isEmpty()) { return null; } Set<Statement> set = stmtBySubject.get(key); if (set == null) { stmtBySubject.put(key, set = new TreeSet<Statement>(comparator)); } set.addAll(matches); if (firstMatch.isEmpty()) { // repeat blank node values queueSize += matches.size(); } else { if (repeatBlankNodes && key.getSubject() instanceof BNode && isStillReferenced(key)) { blankReferences.addAll(matches); } blanks.remove(key.getSubject(), null, null, key.getContext()); } return set; }
private synchronized Set<Statement> queueBlankStatements(SubjectInContext key) { Model firstMatch = blanks.filter(key.getSubject(), null, null, key.getContext()); Model matches = firstMatch.isEmpty() ? blankReferences.filter(key.getSubject(), null, null, key.getContext()) : firstMatch; if (matches.isEmpty()) { return null; } Set<Statement> set = stmtBySubject.get(key); if (set == null) { stmtBySubject.put(key, set = new TreeSet<>(comparator)); } set.addAll(matches); if (firstMatch.isEmpty()) { // repeat blank node values queueSize += matches.size(); } else { if (repeatBlankNodes && key.getSubject() instanceof BNode && isStillReferenced(key)) { blankReferences.addAll(matches); } blanks.remove(key.getSubject(), null, null, key.getContext()); } return set; }
private static Statement getIDStatement(Model model, String repositoryID) { Literal idLiteral = SimpleValueFactory.getInstance().createLiteral(repositoryID); Model idStatementList = model.filter(null, REPOSITORYID, idLiteral); if (idStatementList.size() == 1) { return idStatementList.iterator().next(); } else if (idStatementList.isEmpty()) { return null; } else { throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID); } }
private static Statement getIDStatement(Model model, String repositoryID) { Literal idLiteral = SimpleValueFactory.getInstance().createLiteral(repositoryID); Model idStatementList = model.filter(null, REPOSITORYID, idLiteral); if (idStatementList.size() == 1) { return idStatementList.iterator().next(); } else if (idStatementList.isEmpty()) { return null; } else { throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID); } }
Model more = added.filter(null, null, null, ctx); Model alt = RepositoryConfigUtil.getRepositoryConfigModel(added, id); if (!less.isEmpty() || !more.isEmpty() || alt != null) { Model model = new TreeModel(committed.filter(null, null, null, getContext(id))); model.removeAll(less); model.addAll(alt); if (model.isEmpty()) { manager.removeRepository(id);
@Override public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Model graph; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { graph = new LinkedHashModel(Iterations.asList(statements)); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Model deserializedGraph = (Model) in.readObject(); in.close(); assertThat(deserializedGraph.isEmpty(), is(equalTo(false))); for (Statement st : deserializedGraph) { assertThat(graph, hasItem(st)); assertThat(testCon.hasStatement(st, true), is(equalTo(true))); } }
final boolean matched = !model.isEmpty(); final boolean hasCddb = metadata.get(CDDB).isPresent();
@Test public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Model graph; try (RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true)) { graph = new LinkedHashModel(statements.asList()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Model deserializedGraph = (Model) in.readObject(); in.close(); assertFalse(deserializedGraph.isEmpty()); for (Statement st : deserializedGraph) { assertTrue(graph.contains(st)); assertTrue(testCon.hasStatement(st, true)); } }
if (statements.isEmpty()) throw new IllegalStateException("No ontology entry found for: " + resource.toString());
if (statements.isEmpty()) throw new IllegalStateException("No ontology entry found for: " + resource.toString());