@Override public void removeSubDataProperty(String subDataPropertyName, String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLDataProperty subDataProperty = factory.getOWLDataProperty(IRI.create(prefix + subDataPropertyName)); OWLAxiom axiom = factory.getOWLSubDataPropertyOfAxiom(subDataProperty, dataProperty); axiom = changeManager.getAnnotatedAxiom(axiom); RemoveAxiom removeAxiom = new RemoveAxiom(localContext, axiom); try { synchronized (this) { changeManager.validateRemovalChange(axiom); manager.applyChange(removeAxiom); } } catch (RemovalException ex) { logger.severe( ex.getMessage() + " Change ( removeSubDataProperty " + subDataPropertyName + " of " + dataPropertyName + ") will not be applied."); } }
@Override public void removeDataProperty(String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLAxiom axiom = factory.getOWLDeclarationAxiom(dataProperty); axiom = changeManager.getAnnotatedAxiom(axiom); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLAxiom ax : localContext.getReferencingAxioms(dataProperty)) { ax = ax.getAxiomWithoutAnnotations(); ax = changeManager.getAnnotatedAxiom(ax); changes.add(new RemoveAxiom(localContext, ax)); } try { synchronized (this) { changeManager.validateRemovalChange(axiom); manager.applyChanges(changes); } } catch (RemovalException ex) { logger.severe( ex.getMessage() + "Data property not defined in Ontology or not defined by " + "this application. Change ( removeDataProperty" + dataPropertyName + ") will not be applied. "); } }
@Override public void addDataPropertyFloatRange(String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLDatatype floatDatatype = factory.getFloatOWLDatatype(); OWLAxiom axiom = factory.getOWLDataPropertyRangeAxiom(dataProperty, floatDatatype); axiom = changeManager.getAnnotatedAxiom(axiom); AddAxiom addAxiom = new AddAxiom(localContext, axiom); manager.applyChange(addAxiom); }
@Override public void addDataPropertyDomain(String dataPropertyName, String domainName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLClass domain = factory.getOWLClass(IRI.create(prefix + domainName)); OWLAxiom axiom = factory.getOWLDataPropertyDomainAxiom(dataProperty, domain); axiom = changeManager.getAnnotatedAxiom(axiom); AddAxiom addAxiom = new AddAxiom(localContext, axiom); manager.applyChange(addAxiom); }
@Override public void addDataProperty(String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLAxiom axiom = factory.getOWLDeclarationAxiom(dataProperty); axiom = changeManager.getAnnotatedAxiom(axiom); AddAxiom addAxiom = new AddAxiom(localContext, axiom); try { synchronized (this) { changeManager.validateAddChange(axiom); manager.applyChange(addAxiom); } } catch (DeclarationException ex) { logger.info( ex.getMessage() + "Change ( addDataProperty " + dataPropertyName + " ) will not be applied."); } }
@Override public void removeDataPropertyBooleanRange(String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLDatatype booleanDatatype = factory.getBooleanOWLDatatype(); OWLAxiom axiom = factory.getOWLDataPropertyRangeAxiom(dataProperty, booleanDatatype); axiom = changeManager.getAnnotatedAxiom(axiom); RemoveAxiom removeAxiom = new RemoveAxiom(localContext, axiom); try { synchronized (this) { changeManager.validateRemovalChange(axiom); manager.applyChange(removeAxiom); } } catch (RemovalException ex) { logger.severe( ex.getMessage() + " Change ( removeDataPropertyBooleanRange" + dataPropertyName + ") will not be applied."); } }
@Override public void addSubDataProperty(String subDataPropertyName, String dataPropertyName) { OWLDataFactory factory = manager.getOWLDataFactory(); OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create(prefix + dataPropertyName)); OWLDataProperty subDataProperty = factory.getOWLDataProperty(IRI.create(prefix + subDataPropertyName)); OWLAxiom axiom = factory.getOWLSubDataPropertyOfAxiom(subDataProperty, dataProperty); axiom = changeManager.getAnnotatedAxiom(axiom); AddAxiom addAxiom = new AddAxiom(localContext, axiom); try { synchronized (this) { changeManager.validateAddSubDataPropertyChange(axiom, subDataProperty, dataProperty); manager.applyChange(addAxiom); } } catch (DeclarationException ex) { logger.info( ex.getMessage() + " Change ( addSubDataProperty " + subDataPropertyName + " of " + dataPropertyName + " ) will not be applied."); } catch (RedundancyException ex) { synchronized (this) { removeSubDataProperty(ex.getSubCls(), ex.getCls()); manager.applyChange(addAxiom); } } catch (CycleException ex) { logger.severe( ex.getMessage() + " Change ( addSubDataProperty " + subDataPropertyName + " of " + dataPropertyName + ") will not be applied."); } }