private Set<NonLiteral> getSiblings(NonLiteral resource, TripleCollection base) { Set<Resource> parents = new HashSet<Resource>(); { Iterator<Triple> parentTriples = base.filter(resource, parentProperty, null); while (parentTriples.hasNext()) { parents.add(parentTriples.next().getObject()); } } Set<NonLiteral> resultSet = new HashSet<NonLiteral>(); for (Resource parent : parents) { Iterator<Triple> childTriples = base.filter(null, parentProperty, parent); while (childTriples.hasNext()) { resultSet.add(childTriples.next().getSubject()); } } return resultSet; }
private TripleCollection getMergedTc() { TripleCollection result = new SimpleMGraph(); // Takes less memory than the Indexed one for (OWLOntologyID key : listManagedOntologies()) { // TODO when implemented, switch to true. TripleCollection managed = getOntology(key, TripleCollection.class, false); Set<Resource> exclusions = new HashSet<Resource>(); Iterator<Triple> it = managed.filter(null, RDF.type, OWL.Ontology); while (it.hasNext()) exclusions.add(it.next().getSubject()); for (Triple t : managed) if (!exclusions.contains(t.getSubject())) result.add(t); } // TODO Purge property usage return result; }