"Failed to create OntoNet session. The Refactor Engine requires its own new session to execute.");
log.debug("Refactor enhancement job will run in session '{}'.", session.getID());
// Retrieve and filter the metadata graph for entities recognized by the engines.
final MGraph metadataGraph = ci.getMetadata(), signaturesGraph = new IndexedMGraph();
// FIXME the Stanbol Enhancer vocabulary should be retrieved from somewhere in the enhancer API.
final UriRef ENHANCER_ENTITY_REFERENCE = new UriRef(
"http://fise.iks-project.eu/ontology/entity-reference");
Iterator<Triple> tripleIt = metadataGraph.filter(null, ENHANCER_ENTITY_REFERENCE, null);
while (tripleIt.hasNext()) {
// Get the entity URI
Resource obj = tripleIt.next().getObject();
if (!(obj instanceof UriRef)) {
log.warn("Invalid UriRef for entity reference {}. Skipping.", obj);
continue;
}
final String entityReference = ((UriRef) obj).getUnicodeString();
log.debug("Trying to resolve entity {}", entityReference);
// Populate the entity signatures graph, by querying either the Entity Hub or the dereferencer.
if (engineConfiguration.isEntityHubUsed()) {
MGraph result = populateWithEntity(entityReference, signaturesGraph);
if (result != signaturesGraph && result != null) {
log.warn("Entity Hub query added triples to a new graph instead of populating the supplied one!"
+ " New signatures will be discarded.");
}
} else try {
OntologyInputSource<TripleCollection,?> source = new GraphContentSourceWithPhysicalIRI(
dereferencer.resolve(entityReference), IRI.create(entityReference));
signaturesGraph.addAll(source.getRootOntology());
} catch (FileNotFoundException e) {
log.error("Failed to dereference entity " + entityReference + ". Skipping.", e);
continue;
}
}