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;
  }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 /**
  * Used by {@link #testRetrival()} to validate that an Entity is correctly retrieved by the tested
  * {@link ClerezzaYard}s.
  *
  * @param entity key - URI; value - expected RDF data
  */
 private void validateEntity(ClerezzaYard yard, Entry<UriRef, TripleCollection> entity) {
   Representation rep = yard.getRepresentation(entity.getKey().getUnicodeString());
   assertNotNull(
       "The Representation for " + entity.getKey() + "is missing in the " + yard.getId(), rep);
   assertTrue("RdfRepresentation expected", rep instanceof RdfRepresentation);
   TripleCollection repGraph = ((RdfRepresentation) rep).getRdfGraph();
   for (Iterator<Triple> triples = entity.getValue().iterator(); triples.hasNext(); ) {
     Triple triple = triples.next();
     assertTrue(
         "Data of Representation " + entity.getKey() + "is missing the triple " + triple,
         repGraph.remove(triple));
   }
   assertTrue(
       repGraph.size()
           + " unexpected Triples are present in the "
           + "Representation of Entity "
           + entity.getKey(),
       repGraph.isEmpty());
 }
Ejemplo n.º 4
0
 @Override
 public int providedTriplesCount(TripleCollection base) {
   // raw guess
   return (int) (base.size() * 0.01);
 }