ExtractOperation { protected static OWLAnnotationAxiom getIsDefinedBy(OWLEntity entity, Map<IRI, IRI> sourceMap) { String iri = entity.getIRI().toString(); IRI base; if (sourceMap != null && sourceMap.containsKey(entity.getIRI())) { base = sourceMap.get(entity.getIRI()); } else { if (iri.contains("#")) { if (iri.contains(".owl#")) { String baseStr = iri.substring(0, iri.lastIndexOf("#")).toLowerCase(); base = IRI.create(baseStr); } else { String baseStr = iri.substring(0, iri.lastIndexOf("#")).toLowerCase() + ".owl"; base = IRI.create(baseStr); } } else if (iri.contains("_")) { String baseStr = iri.substring(0, iri.lastIndexOf("_")).toLowerCase() + ".owl"; base = IRI.create(baseStr); } else if (iri.contains("/")) { String baseStr = iri.substring(0, iri.lastIndexOf("/")).toLowerCase() + ".owl"; base = IRI.create(baseStr); } else { logger.warn("Unable to get source for IRI " + iri); return null; } } return dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), base); }  static Map<String, String> getDefaultOptions(); static OWLOntology extract(
      OWLOntology inputOntology, Set<IRI> terms, IRI outputIRI, ModuleType moduleType); static OWLOntology extract(
      OWLOntology inputOntology,
      Set<IRI> terms,
      IRI outputIRI,
      ModuleType moduleType,
      Map<String, String> options); static OWLOntology extract(
      OWLOntology inputOntology,
      Set<IRI> terms,
      IRI outputIRI,
      ModuleType moduleType,
      Map<String, String> options,
      Map<IRI, IRI> sourceMap);  }
@Test public void testGetIsDefinedBy() { OWLAnnotationProperty isDefinedBy = dataFactory.getRDFSIsDefinedBy(); IRI source = IRI.create("http: IRI bfoSource = IRI.create("http: OWLEntity entity = dataFactory.getOWLClass(IRI.create("http: OWLAnnotationAxiom axiom = dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), source); assertEquals(axiom, ExtractOperation.getIsDefinedBy(entity, null)); Map<IRI, IRI> sourceMap = new HashMap<>(); sourceMap.put(IRI.create("http: axiom = dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), bfoSource); assertEquals(axiom, ExtractOperation.getIsDefinedBy(entity, sourceMap)); entity = dataFactory.getOWLClass(IRI.create("http: axiom = dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), source); ExtractOperation.getIsDefinedBy(entity, null); assertEquals(axiom, ExtractOperation.getIsDefinedBy(entity, null)); entity = dataFactory.getOWLClass(IRI.create("http: axiom = dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), source); ExtractOperation.getIsDefinedBy(entity, null); assertEquals(axiom, ExtractOperation.getIsDefinedBy(entity, null)); entity = dataFactory.getOWLClass(IRI.create("http: axiom = dataFactory.getOWLAnnotationAssertionAxiom(isDefinedBy, entity.getIRI(), source); ExtractOperation.getIsDefinedBy(entity, null); assertEquals(axiom, ExtractOperation.getIsDefinedBy(entity, null)); }