public void visit(OWLObjectComplementOf owlNot) { try { owlNot.getOperand().accept(this); ClassPointer cp = getLastClassPointer(); lastClassPointer = faCTPlusPlus.getConceptNot(cp); } catch (Exception e) { throw new FaCTPlusPlusRuntimeException(e); } }
protected OWLDescription doReplacing(GenericOWLDescriptionRewritingContext context) { // cast down the replacment context OWLDescription initialTerm = ((PartialDescriptionRewritingApproximationTypeContext) context).getOwlDescription(); ApproximationType approximationType = ((PartialDescriptionRewritingApproximationTypeContext) context).getApproximationType(); Set<URI> notS = ((PartialDescriptionRewritingApproximationTypeContext) context).getNotS(); // perform replacement if possible OWLDescription replacement = getRewritingStrategy() .rewrite( new PartialDescriptionRewritingApproximationTypeContext( initialTerm, approximationType, notS)); if (replacement == null) { // there is a replacement for this term throw new IllegalArgumentException("Rewritingstrategy never should deliver null back"); } // recurse down the object tree // If the term is negated, change the approx-type if (replacement instanceof OWLObjectComplementOf) { OWLObjectComplementOf complement = (OWLObjectComplementOf) replacement; OWLDescription filler = complement.getOperand(); if (filler instanceof OWLObjectIntersectionOf) { OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) filler; Set<OWLDescription> subterms = new HashSet<OWLDescription>(); // recurse into operands for (OWLDescription subTerm : intersection.getOperands()) { subterms.add( doReplacing( new PartialDescriptionRewritingApproximationTypeContext( subTerm, approximationType.invert(), notS))); } // return a freshly constructed Complementobject with intersection return getOwlDataFactory() .getOWLObjectComplementOf(getOwlDataFactory().getOWLObjectIntersectionOf(subterms)); } else if (filler instanceof OWLObjectUnionOf) { OWLObjectUnionOf union = (OWLObjectUnionOf) filler; Set<OWLDescription> subterms = new HashSet<OWLDescription>(); // recurse into operands for (OWLDescription subTerm : union.getOperands()) { subterms.add( doReplacing( new PartialDescriptionRewritingApproximationTypeContext( subTerm, approximationType.invert(), notS))); } // return a freshly constructed Complementobject with intersection return getOwlDataFactory() .getOWLObjectComplementOf(getOwlDataFactory().getOWLObjectUnionOf(subterms)); } else if (filler instanceof OWLObjectMaxCardinalityRestriction) { OWLObjectMaxCardinalityRestriction maxR = (OWLObjectMaxCardinalityRestriction) replacement; // recurse into subterm // return a freshly constructed Complementobject with intersection return getOwlDataFactory() .getOWLObjectComplementOf( getOwlDataFactory() .getOWLObjectMaxCardinalityRestriction( maxR.getProperty(), maxR.getCardinality(), doReplacing( new PartialDescriptionRewritingApproximationTypeContext( maxR.getFiller(), approximationType.invert().invert(), notS)))); } else if (filler instanceof OWLObjectMinCardinalityRestriction) { OWLObjectMinCardinalityRestriction minR = (OWLObjectMinCardinalityRestriction) replacement; return getOwlDataFactory() .getOWLObjectComplementOf( getOwlDataFactory() .getOWLObjectMinCardinalityRestriction( minR.getProperty(), minR.getCardinality(), doReplacing( new PartialDescriptionRewritingApproximationTypeContext( minR.getFiller(), approximationType.invert(), notS)))); } } else { // term is not negatated if (replacement instanceof OWLObjectIntersectionOf) { OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) replacement; Set<OWLDescription> subterms = new HashSet<OWLDescription>(); // recurse into operands for (OWLDescription subTerm : intersection.getOperands()) { subterms.add( doReplacing( new PartialDescriptionRewritingApproximationTypeContext( subTerm, approximationType, notS))); } // return a freshly constructed intersection return getOwlDataFactory().getOWLObjectIntersectionOf(subterms); } else if (replacement instanceof OWLObjectUnionOf) { OWLObjectUnionOf union = (OWLObjectUnionOf) replacement; Set<OWLDescription> subterms = new HashSet<OWLDescription>(); // recurse into operands for (OWLDescription subTerm : union.getOperands()) { subterms.add( doReplacing( new PartialDescriptionRewritingApproximationTypeContext( subTerm, approximationType, notS))); } // return a freshly constructed Complementobject with intersection return getOwlDataFactory().getOWLObjectUnionOf(subterms); } else if (replacement instanceof OWLObjectMaxCardinalityRestriction) { OWLObjectMaxCardinalityRestriction maxR = (OWLObjectMaxCardinalityRestriction) replacement; // recurse into subterm // return a freshly constructed Complementobject with intersection return getOwlDataFactory() .getOWLObjectMaxCardinalityRestriction( maxR.getProperty(), maxR.getCardinality(), doReplacing( new PartialDescriptionRewritingApproximationTypeContext( maxR.getFiller(), approximationType.invert(), notS))); } else if (replacement instanceof OWLObjectMinCardinalityRestriction) { OWLObjectMinCardinalityRestriction minR = (OWLObjectMinCardinalityRestriction) replacement; return getOwlDataFactory() .getOWLObjectMinCardinalityRestriction( minR.getProperty(), minR.getCardinality(), doReplacing( new PartialDescriptionRewritingApproximationTypeContext( minR.getFiller(), approximationType, notS))); } } // end recursion return replacement; }
// DONE @Override public void visit(OWLObjectComplementOf desc) { desc.getOperand().accept(this); OWLDescription d = this.getRelevantDescription(); this.rebuiltObjects.add(this.factory.getOWLObjectComplementOf(d)); }