Ejemplo n.º 1
0
 @Override
 public void visit(OWLDeclarationAxiom axiom) {
   axiom.getEntity().accept(this);
   OWLEntity ent = (OWLEntity) obj;
   obj = dataFactory.getOWLDeclarationAxiom(ent, duplicateAxiomAnnotations(axiom));
 }
 @Override
 public void visit(OWLDeclarationAxiom axiom) {
   handleObject(axiom);
   axiom.getEntity().accept(this);
 }
Ejemplo n.º 3
0
    @Override
    public void ontologiesChanged(List<? extends OWLOntologyChange> changes) throws OWLException {
      Map<OWLEntity, OWLEntity> renamings = new HashMap<OWLEntity, OWLEntity>();
      Set<OWLEntity> removals = new HashSet<OWLEntity>();

      for (int idx = 0; idx < changes.size(); idx++) {
        OWLOntologyChange change = changes.get(idx);
        if (change instanceof SetOntologyID) {
          IRI newiri = ((SetOntologyID) change).getNewOntologyID().getOntologyIRI();

          if (newiri == null) continue;

          IRI oldiri = ((SetOntologyID) change).getOriginalOntologyID().getOntologyIRI();

          log.debug("Ontology ID changed");
          log.debug("Old ID: {}", oldiri);
          log.debug("New ID: {}", newiri);

          OBDAModel model = obdamodels.get(oldiri.toURI());

          if (model == null) {
            setupNewOBDAModel();
            model = getActiveOBDAModel();
          }

          PrefixManager prefixManager = model.getPrefixManager();
          prefixManager.addPrefix(PrefixManager.DEFAULT_PREFIX, newiri.toURI().toString());

          obdamodels.remove(oldiri.toURI());
          obdamodels.put(newiri.toURI(), model);
          continue;

        } else if (change instanceof AddAxiom) {
          OWLAxiom axiom = change.getAxiom();
          if (axiom instanceof OWLDeclarationAxiom) {
            OWLEntity entity = ((OWLDeclarationAxiom) axiom).getEntity();
            OBDAModel activeOBDAModel = getActiveOBDAModel();
            if (entity instanceof OWLClass) {
              OWLClass oc = (OWLClass) entity;
              OClass c = ofac.createClass(oc.getIRI().toString());
              activeOBDAModel.declareClass(c);
            } else if (entity instanceof OWLObjectProperty) {
              OWLObjectProperty or = (OWLObjectProperty) entity;
              ObjectPropertyExpression r = ofac.createObjectProperty(or.getIRI().toString());
              activeOBDAModel.declareObjectProperty(r);
            } else if (entity instanceof OWLDataProperty) {
              OWLDataProperty op = (OWLDataProperty) entity;
              DataPropertyExpression p = ofac.createDataProperty(op.getIRI().toString());
              activeOBDAModel.declareDataProperty(p);
            }
          }

        } else if (change instanceof RemoveAxiom) {
          OWLAxiom axiom = change.getAxiom();
          if (axiom instanceof OWLDeclarationAxiom) {
            OWLEntity entity = ((OWLDeclarationAxiom) axiom).getEntity();
            OBDAModel activeOBDAModel = getActiveOBDAModel();
            if (entity instanceof OWLClass) {
              OWLClass oc = (OWLClass) entity;
              OClass c = ofac.createClass(oc.getIRI().toString());
              activeOBDAModel.unDeclareClass(c);
            } else if (entity instanceof OWLObjectProperty) {
              OWLObjectProperty or = (OWLObjectProperty) entity;
              ObjectPropertyExpression r = ofac.createObjectProperty(or.getIRI().toString());
              activeOBDAModel.unDeclareObjectProperty(r);
            } else if (entity instanceof OWLDataProperty) {
              OWLDataProperty op = (OWLDataProperty) entity;
              DataPropertyExpression p = ofac.createDataProperty(op.getIRI().toString());
              activeOBDAModel.unDeclareDataProperty(p);
            }
          }
        }

        if (idx + 1 >= changes.size()) {
          continue;
        }

        if (change instanceof RemoveAxiom && changes.get(idx + 1) instanceof AddAxiom) {
          // Found the pattern of a renaming refactoring
          RemoveAxiom remove = (RemoveAxiom) change;
          AddAxiom add = (AddAxiom) changes.get(idx + 1);

          if (!(remove.getAxiom() instanceof OWLDeclarationAxiom
              && add.getAxiom() instanceof OWLDeclarationAxiom)) {
            continue;
          }
          // Found the patter we are looking for, a remove and add of
          // declaration axioms
          OWLEntity olde = ((OWLDeclarationAxiom) remove.getAxiom()).getEntity();
          OWLEntity newe = ((OWLDeclarationAxiom) add.getAxiom()).getEntity();
          renamings.put(olde, newe);

        } else if (change instanceof RemoveAxiom
            && ((RemoveAxiom) change).getAxiom() instanceof OWLDeclarationAxiom) {
          // Found the pattern of a deletion
          OWLDeclarationAxiom declaration = (OWLDeclarationAxiom) ((RemoveAxiom) change).getAxiom();
          OWLEntity removedEntity = declaration.getEntity();
          removals.add(removedEntity);
        }
      }

      // Applying the renaming to the OBDA model
      OBDAModel obdamodel = getActiveOBDAModel();
      for (OWLEntity olde : renamings.keySet()) {
        OWLEntity removedEntity = olde;
        OWLEntity newEntity = renamings.get(removedEntity);

        // This set of changes appears to be a "renaming" operation,
        // hence we will modify the OBDA model accordingly
        Predicate removedPredicate = getPredicate(removedEntity);
        Predicate newPredicate = getPredicate(newEntity);

        obdamodel.renamePredicate(removedPredicate, newPredicate);
      }

      // Applying the deletions to the obda model
      for (OWLEntity removede : removals) {
        Predicate removedPredicate = getPredicate(removede);
        obdamodel.deletePredicate(removedPredicate);
      }
    }
 public void visit(OWLDeclarationAxiom axiom) {
   type = AXIOM_TYPE_INDEX_BASE + axiom.getAxiomType().getIndex();
 }
 public void visit(OWLDeclarationAxiom axiom) {
   axiom.getEntity().accept(this);
   processAxiomAnnotations(axiom);
 }
Ejemplo n.º 6
0
 @Override
 public void visit(OWLDeclarationAxiom axiom) {
   write("Declaration");
   axiom.getEntity().accept(this);
 }