try {
// try {
IRIMap.clear();
tripleProcessor.fine("Total number of triples: " + count);
RDFXMLOntologyFormat format = getOntologyFormat();
// First mop up any rules triples
SWRLRuleTranslator translator = new SWRLRuleTranslator(this);
for (IRI ruleIRI : swrlRules) {
translator.translateRule(ruleIRI);
}
// We need to mop up all remaining triples. These triples will be in the
// triples by subject map. Other triples which reside in the triples by
// predicate (single valued) triple aren't "root" triples for axioms. First
// we translate all system triples and then go for triples whose predicates
// are not system/reserved vocabulary IRIs to translate these into ABox assertions
// or annotationIRIs
for (IRI subject : new ArrayList<IRI>(resTriplesBySubject.keySet())) {
Map<IRI, Set<IRI>> map = resTriplesBySubject.get(subject);
if (map == null) {
continue;
}
for (IRI predicate : new ArrayList<IRI>(map.keySet())) {
Set<IRI> objects = map.get(predicate);
if (objects == null) {
continue;
}
for (IRI object : new ArrayList<IRI>(objects)) {
// We don't handle x rdf:type owl:Axiom because these must be handled after everything else
// so that the "base triples" that represent the axiom with out the annotations get mopped up first
if (!(predicate.equals(OWLRDFVocabulary.RDF_TYPE.getIRI()) && (object.equals(OWLRDFVocabulary.OWL_AXIOM.getIRI()) || object.equals(OWLRDFVocabulary.OWL_ALL_DISJOINT_CLASSES.getIRI())))) {
handle(subject, predicate, object);
}
}
}
}
// Now handle axiom annotations
// TODO: TIDY UP THIS COPY AND PASTE HACK!
for (IRI subject : new ArrayList<IRI>(resTriplesBySubject.keySet())) {
Map<IRI, Set<IRI>> map = resTriplesBySubject.get(subject);
if (map == null) {
continue;
}
for (IRI predicate : new ArrayList<IRI>(map.keySet())) {
Set<IRI> objects = map.get(predicate);
if (objects == null) {
continue;
}
for (IRI object : new ArrayList<IRI>(objects)) {
if ((predicate.equals(OWLRDFVocabulary.RDF_TYPE.getIRI()) && (object.equals(OWLRDFVocabulary.OWL_AXIOM.getIRI()) || object.equals(OWLRDFVocabulary.OWL_ALL_DISJOINT_CLASSES.getIRI())))) {
handle(subject, predicate, object);
}
}
}
}
// TODO: TIDY UP! This is a copy and paste hack!!
// Now for the ABox assertions and annotationIRIs
for (IRI subject : new ArrayList<IRI>(resTriplesBySubject.keySet())) {
Map<IRI, Set<IRI>> map = resTriplesBySubject.get(subject);
if (map == null) {
continue;
}
for (IRI predicate : new ArrayList<IRI>(map.keySet())) {
Set<IRI> objects = map.get(predicate);
if (objects == null) {
continue;
}
for (IRI object : new ArrayList<IRI>(objects)) {
for (AbstractResourceTripleHandler resTripHandler : resourceTripleHandlers) {
if (resTripHandler.canHandle(subject, predicate, object)) {
resTripHandler.handleTriple(subject, predicate, object);
break;
}
}
}
}
}
for (IRI subject : new ArrayList<IRI>(litTriplesBySubject.keySet())) {
Map<IRI, Set<OWLLiteral>> map = litTriplesBySubject.get(subject);
if (map == null) {
continue;
}
for (IRI predicate : new ArrayList<IRI>(map.keySet())) {
Set<OWLLiteral> objects = map.get(predicate);
for (OWLLiteral object : new ArrayList<OWLLiteral>(objects)) {
handle(subject, predicate, object);
}
}
}
// translateDanglingEntities();
if (format != null) {
RDFOntologyFormat.ParserMetaData metaData = new RDFOntologyFormat.ParserMetaData(count, RDFOntologyFormat.OntologyHeaderStatus.PARSED_ONE_HEADER);
format.setParserMetaData(metaData);
}
// Do we need to change the ontology IRI?
IRI ontologyIRIToSet = chooseOntologyIRI();